geggleto/setter-strategy
Composer 安装命令:
composer require geggleto/setter-strategy
包简介
Alternative dispatch strategy for slim 3
README 文档
README
setter-injection-strategy
This package is intended to replace the default Invocation handler in Slim.
This strategy forces controllers to implement SetterInjectionReceiver which tells Slim to set the Response, Request, and Arg instead of
passing it through the method signature. This saves space on all of your action methods in your controller.
In short it will turn this.
class abcController { //... public function myAction (Request $request, Response $response, $args = []) { //.. } //... }
Into This.
class abcController implements SetterInjectionReceiver { //.. Implement and store the Objects somewhere up here. //... public function myAction () { //.. This is now much more Slim 2 style } //... }
Or this if you have arguments
class abcController implements SetterInjectionReceiver { //.. Implement and store the Objects somewhere up here. //... public function myAction ($arg1, $arg2, $arg3) { //.. This is now much more Slim 2 style } //... }
Install
This package is available via Composer. composer install geggleto/setter-strategy
Usage
There are some configuration changes you will need to make in your Slim application. If you only wish to use SetterInjection on some of your callables, It will default back to using the RequestResponseArgs style if your controller does not implement the Receiver Interface
// Setup the Strategy in the container by adding a factory method like below. $container['foundHandler'] = function ($c) { return new SetterInjectionStrategy(); };
统计信息
- 总下载量: 24
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 3
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-03-04