承接 mathsgod/light-server 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

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

  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.

统计信息

  • 总下载量: 46
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-03-18