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
Requires
- php: ^8.1
- laminas/laminas-diactoros: ^3.5
- laminas/laminas-httphandlerrunner: ^2.11
- laminas/laminas-stratigility: ^4.1
- league/route: ^6.0
Requires (Dev)
- phpunit/phpunit: ^12.5
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
- Create a
pagesfolder in your project root - Create a
pages/index.phpfile
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→/aboutpages/blog/index.php→/blogpages/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.