pine3ree/p3-mezzio-controller
Composer 安装命令:
composer require pine3ree/p3-mezzio-controller
包简介
A middleware wrapper for controller-like classes for mezzio/mezzio
README 文档
README
A middleware wrapper for controller-like classes for mezzio/mezzio
STATUS
WIP!
Installation
You can install this library using Composer (with "minimum-stability": "dev"):
$ composer require pine3ree/p3-mezzio-controller
Documentation
You can now define 2 new types of route handled by generic-class controller methods:
Define a route using the callable-string format:
$app->get('/home/kitchen', 'App\Controller\Home::kitchen', 'home/kitchen');
Define a route using the callable-array format:
use App\Controller\Home; //... $app->get('/home/bedroom', [Home::class, 'bedroom'], 'home/bedroom');
Define routes using a configuration file:
// config/autoload/routes.global.php use App\Controller\Home; use App\Middleware\BeforeHomeControllerMiddleware; use App\Middleware\AfterHomeControllerMiddleware; return [ 'routes' => [ 'home/kitchen' => [ 'path' => '/home/kitchen', 'middleware' => 'App\Controller\Home::kitchen', ], 'home/bedroom' => [ 'path' => '/home/kitchen', 'middleware' => [Home::class, 'bedroom'], ], 'home/living-room' => [ 'path' => '/home/living-room', 'middleware' => [ BeforeHomeControllerMiddleware::class, [Home::class, 'livingRoom'], AfterHomeControllerMiddleware::class, ], ], ], ];
These definitions works only on the condition that if the controller class exists and the target method is public.
As of now the target controller-method signature may be one of the following:
use Psr\Http\Message\ServerRequestInterface; use Psr\Http\Message\ResponseInterface; class Home { public function kitchen(ServerRequestInterface $request): ResponseInterface { // return a response } public function bedroom(): ResponseInterface { // return a response } }
The controller class may be a simple contructor-less class. In most of cases it will have dependencies so it muste me defined in the container configuration along with its factory.
TODO:
- Add strategy to pass request attributes as arguments into the target controller-method
- Add strategy to allow null, string, array, xml, etc... return values from the controller-methods and build appropriate response based on the return type.
pine3ree/p3-mezzio-controller 适用场景与选型建议
pine3ree/p3-mezzio-controller 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 10 次下载、GitHub Stars 达 0, 最近一次更新时间为 2020 年 04 月 15 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「routing」 「controller」 「middleware」 「psr-15」 「mezzio」 「pine3ree」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 pine3ree/p3-mezzio-controller 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 pine3ree/p3-mezzio-controller 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 pine3ree/p3-mezzio-controller 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Give your JS App some Backbone with Models, Views, Collections, and Events.
Shoot aims to make providing data to your templates more manageable
Write down your routing mapping at one place
Flight routing is a simple, fast PHP router that is easy to get integrated with other routers.
Slim Framework 3 CSRF protection middleware utilities
Cloudflare Middleware For Guzzle
统计信息
- 总下载量: 10
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 6
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: BSD-3-Clause
- 更新时间: 2020-04-15