chubbyphp / chubbyphp-framework
一个尽可能简单、高性能的PSR-15中间件微框架,主要面向希望了解他们所使用的所有供应商的开发者。
5.1.1
2023-12-02 20:01 UTC
Requires
- php: ^8.1
- chubbyphp/chubbyphp-http-exception: ^1.1
- psr/container: ^1.1.2|^2.0.2
- psr/http-factory: ^1.0.2
- psr/http-factory-implementation: ^1.0
- psr/http-message: ^1.1|^2.0
- psr/http-message-implementation: ^1.0|^2.0
- psr/http-server-handler: ^1.0.2
- psr/http-server-middleware: ^1.0.2
- psr/log: ^2.0|^3.0
Requires (Dev)
- chubbyphp/chubbyphp-dev-helper: dev-master
- chubbyphp/chubbyphp-mock: ^1.7
- guzzlehttp/psr7: ^2.6.1
- http-interop/http-factory-guzzle: ^1.2
- infection/infection: ^0.27.8
- laminas/laminas-diactoros: ^3.3
- nyholm/psr7: ^1.8.1
- php-coveralls/php-coveralls: ^2.7.0
- phpstan/extension-installer: ^1.3.1
- phpstan/phpstan: ^1.10.45
- phpunit/phpunit: ^10.4.2
- slim/psr7: ^1.6.1
- sunrise/http-message: ^3.0
- dev-master / 5.1.x-dev
- 5.1.1
- 5.1.0
- 5.0.3
- 5.0.2
- 5.0.1
- 5.0.0
- v4.x-dev
- 4.2.3
- 4.2.2
- 4.2.1
- 4.2.0
- 4.1.0
- 4.0.0
- v3.x-dev
- 3.6.2
- 3.6.1
- 3.6.0
- 3.5.1
- 3.5.0
- 3.4.1
- 3.4.0
- 3.3.0
- 3.2.0
- 3.1.2
- 3.1.1
- 3.1.0
- 3.0.0
- v2.x-dev
- 2.8.2
- 2.8.1
- 2.8.0
- 2.7.0
- 2.6.2
- 2.6.1
- 2.6.0
- 2.5.0
- 2.4.1
- 2.4.0
- 2.3.0
- 2.2.1
- 2.2.0
- 2.2-beta1
- 2.1.0
- 2.0.0
- 2.0-beta2
- 2.0-beta1
- v1.x-dev
- 1.2.2
- 1.2.1
- 1.2.0
- 1.1.1
- 1.1.0
- 1.0.0
- 1.0-beta3
- 1.0-beta2
- 1.0-beta1
- 1.0-alpha9
- 1.0-alpha8
- 1.0-alpha7
- 1.0-alpha6
- 1.0-alpha5
- 1.0-alpha4
- 1.0-alpha3
- 1.0-alpha2
- 1.0-alpha1
This package is auto-updated.
Last update: 2024-09-10 20:15:00 UTC
README
描述
一个尽可能简单、高性能的中间件PSR-15微框架,主要面向希望了解他们所使用的所有供应商的开发者。
要求
- php: ^8.1
- chubbyphp/chubbyphp-http-exception: ^1.1
- psr/container: ^1.1.2|^2.0.2
- psr/http-factory-implementation: ^1.0
- psr/http-factory: ^1.0.2
- psr/http-message-implementation: ^1.0|^2.0
- psr/http-message: ^1.1|^2.0
- psr/http-server-handler: ^1.0.2
- psr/http-server-middleware: ^1.0.2
- psr/log: ^2.0|^3.0
建议
路由器
任何实现了Chubbyphp\Framework\Router\RouteMatcherInterface
的路由器都可以使用。
PSR 7 / PSR 17
- guzzlehttp/psr7: ^2.6.1 (with http-interop/http-factory-guzzle: ^1.2)
- laminas/laminas-diactoros: ^3.3
- nyholm/psr7: ^1.8.1
- slim/psr7: ^1.6.1
- sunrise/http-message: ^3.0
安装
通过Composer安装chubbyphp/chubbyphp-framework。
composer require chubbyphp/chubbyphp-framework "^5.1" \ chubbyphp/chubbyphp-framework-router-fastroute "^2.1" \ slim/psr7 "^1.5"
用法
<?php declare(strict_types=1); namespace App; use Chubbyphp\Framework\Application; use Chubbyphp\Framework\Middleware\ExceptionMiddleware; use Chubbyphp\Framework\Middleware\RouteMatcherMiddleware; use Chubbyphp\Framework\RequestHandler\CallbackRequestHandler; use Chubbyphp\Framework\Router\FastRoute\RouteMatcher; use Chubbyphp\Framework\Router\Route; use Chubbyphp\Framework\Router\RoutesByName; use Psr\Http\Message\ServerRequestInterface; use Slim\Psr7\Factory\ResponseFactory; use Slim\Psr7\Factory\ServerRequestFactory; require __DIR__.'/vendor/autoload.php'; $responseFactory = new ResponseFactory(); $app = new Application([ new ExceptionMiddleware($responseFactory, true), new RouteMatcherMiddleware(new RouteMatcher(new RoutesByName([ Route::get('/hello/{name:[a-z]+}', 'hello', new CallbackRequestHandler( static function (ServerRequestInterface $request) use ($responseFactory) { $response = $responseFactory->createResponse(); $response->getBody()->write(sprintf('Hello, %s', $request->getAttribute('name'))); return $response; } )) ]))), ]); $app->emit($app->handle((new ServerRequestFactory())->createFromGlobals()));
发射器
中间件
请求处理器
路由器
服务器
骨架
迁移
版权
2024 Dominik Zogg