geggleto / helper_classes
此包的最新版本(0.0.5)没有可用的许可信息。
0.0.5
2015-12-23 16:26 UTC
Requires
- slim/slim: ^3.0
README
Slim 3与Slim 2非常不同。这些辅助类将帮助您迁移或在新项目中使用Slim 3。
BaseAction 示例
use \Your\Namespace; class HelloWorldAction extends Geggleto\Helper\BaseAction { public function __construct(ContainerInterface $containerInterface) { parent::__construct($containerInterface); } public function __invoke (ServerRequestInterface $request, ResponseInterface $response, array $args) { $response = $this->view->render($response, "myview.twig", $args); //this will fetch from the container return $response; } } class HelloWorldMiddleware extends Geggleto\Helper\BaseMiddleware { public function __construct(ContainerInterface $containerInterface) { parent::__construct($containerInterface); } public function __invoke (ServerRequestInterface $request, ResponseInterface $response, callable $next) { //Do stuff before your Action $response = $next($request, $response); //Do Stuff After Your Action return $response; } }
设置/配置
无!
使用方法
HelloWorldAction
$app->get('/hello/world', '\Your\Namespace\HelloWorldAction');
HellWorldMiddleware
$app->add('\Your\Namespace\HelloWorldMiddleware');
容器
这些类包含一个容器实例,您可以通过 $this 接收依赖项,就像在Slim 2中一样。