c0pt3r/sonet
Composer 安装命令:
composer require c0pt3r/sonet
包简介
!!WIP!! A simple framework for websites/web APIs
README 文档
README
A simple PHP framework for creating websites and/or web APIs.
It supports routing of HTTP requests with methods GET, POST, PUT and DELETE. Other things too... maybe one day I'll make a doc for it.
Main concepts:
This section is pretty much just a placeholder.
- Application: A global container for all application data. Is also a Router itself (aka: main application router).
- VirtualPath: An extended path that can contain variables, options and aliases.
- Router: An object that contains Routes and is mounted to a VirtualPath. You can have as many as you want.
- Route: An object created by a Router and mounted onto it.
- StatusEvent: An event that is triggered when certain HTTP statuses are encountered.
- Request: A predefined object that contains information about the requested resource.
- Response: A predefined object that contains information about the response to be sent.
- Handler: A user defined callable that accepts Request and Response as parameters. It can be assigned to a Route or a StatusEvent.
Example code:
This code creates a Route that will listen for a request using HTTP method GET.
$app = Sonet\Application::getApp(); $app->get('hello|h/?name', function ($req, $res) { $name = $req->params->name ?? 'world'; $res->html("Hello, $name!"); }); $app->run();
This VirtualPath corresponds to:
/hello/hello/([^/]+)/h/h/([^/]+)
For example,
/hellowill generate "Hello, world!"/h/Einsteinwill generate "Hello, Einstein!"
统计信息
- 总下载量: 2
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-07-20