mathsgod/light-server
最新稳定版本:1.1.0
Composer 安装命令:
composer require mathsgod/light-server
包简介
README 文档
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.
统计信息
- 总下载量: 46
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-03-18