mathsgod/light-server

Installs: 49

Dependents: 1

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 0

Open Issues: 0

pkg:composer/mathsgod/light-server

1.1.0 2025-12-30 09:33 UTC

This package is auto-updated.

Last update: 2025-12-31 07:27:31 UTC


README

A lightweight PHP web framework with a simple file-based routing convention.

Features

  • 🚀 Lightweight design and fast startup
  • 📄 File-system based routing
  • 🛠️ PSR-7 standard support
  • 💪 Built-in middleware system
  • 🔄 Simple HTTP method handling (GET, POST, etc.)

Installation

Install via Composer:

composer require mathsgod/light-server

Quick Start

Basic Setup

  1. Create a pages folder in your project root
  2. Create a pages/index.php file

Starting the Server

<?php

require 'vendor/autoload.php';

(new Light\Server())->run();

Usage

Simple Example

In pages/index.php:

<?php

use Laminas\Diactoros\Response\TextResponse;

return new class() {
    
    public function get()
    {
        return new TextResponse("Hello World");
    }

    public function post()
    {
        return new TextResponse("POST request received");
    }
};

Routing Structure

The page system automatically generates routes based on the file structure:

  • pages/index.php/
  • pages/about.php/about
  • pages/blog/index.php/blog
  • pages/blog/{id}/index.php/blog/{id} (dynamic routes)

Handling HTTP Methods

Define corresponding methods in your page class:

public function get() { }      // GET request
public function post() { }     // POST request
public function put() { }      // PUT request
public function delete() { }   // DELETE request
public function patch() { }    // PATCH request

License

See the LICENSE file for details.