sergonie / framework
Swoole, PSR-7, PSR-15 模块化微反框架。
dev-develop
2021-05-27 00:12 UTC
Requires
- php: >=7.4.0
- igniphp/exception: >=1.0
- laminas/laminas-httphandlerrunner: ^1.4.0
- psr/container: >=2.0.1
- psr/http-message: >=1.0.1
- psr/http-server-middleware: >=1.0.1
- psr/log: >=1.0.2
- psr/simple-cache: >=1.0.1
- sergonie/container: dev-develop
- sergonie/network: dev-develop
- symfony/routing: >=5.2
Requires (Dev)
- league/container: >=1.0.0
- mockery/mockery: ^1.3
- phpstan/phpstan: >=0.9.2
- phpunit/phpunit: ~9.5
Suggests
- ext-swoole: for build in http server support.
This package is auto-updated.
Last update: 2024-09-27 07:49:41 UTC
README
Sergonie 是一个 PHP7 反框架,内置了 swoole 服务器 和模块化架构支持,帮助您快速编写可扩展的 PSR-7 和 PSR-15 兼容的 REST 服务。
其主要目标是尽可能使您的应用程序透明,并减少可见性。
<?php require 'vendor/autoload.php'; use Sergonie\Application\Config; use Sergonie\Application\HttpApplication; use Sergonie\Application\Providers\ConfigProvider; use Sergonie\Network\Http\Response; use Sergonie\Network\Http\Request; $application = new HttpApplication(); // Routing $application->get('/hello/{name}', function (Request $request) : Response { return Response::asText("Hello {$request->getAttribute('name')}."); }); // Middleware - no interfaces no binding with framework code is required in order things to work. $application->use(function($request, /** callable|RequestHandlerInterface */$next) { $response = $next($request); return $response->withAddedHeader('Version', $this->getConfig()->get('version')); }); // Extending application is a brief just create and implement methods for your needs. $application->extend(new class implements ConfigProvider { public function provideConfig(Config $config): void { $config->set('version', '1.0'); } }); $application->run();
安装和需求
Sergonie 框架推荐的安装方式是使用 composer
composer install sergonie/framework
需求
- PHP 7.4 或更高版本
- swoole 扩展以支持内置 http 服务器
新功能
随着 2.0 版本的发布,网络包从框架代码中提取出来,错误处理得到了整体改进,以及服务器的监听器。更多详细信息请查看变更日志文件。
快速入门
或者您可以使用包含引导应用的 快速入门 来开始使用框架。
特性
路由
Sergonie 路由基于非常快速的 symfony 路由库。
PSR-7, PSR-15 支持
Sergonie 完全支持 PSR 消息标准,用于操作 HTTP 响应、请求和 HTTP 中间件。
依赖注入和自动解析
Sergonie 会为您自动解析依赖项,并提供直观的依赖容器。它还允许您使用任何您选择的 PSR 兼容容器。
模块化架构
模块化和可扩展的解决方案是此框架诞生的重要原因之一。只需创建一个模块类,实现所需接口,并通过您的模块扩展应用程序。
性能优良、生产就绪的 http 服务器
安装了 swoole 时,无需 nginx 或 apache,应用程序可以像在 node.js 世界中一样运行。
php examples/build_in_server_example.php
Sergonie 的 http 服务器与 express.js 应用程序一样快,几乎无需配置。
详细文档
详细文档和更多示例可以在 这里 和示例目录中找到。