andrewbreksa/slim-action-helpers
Composer 安装命令:
composer require andrewbreksa/slim-action-helpers
包简介
A set of classes to make Slim 3 a bit easier to work with
README 文档
README
Quick and dirty helper classes for RAD slim 3 development that fully support the __invoke Slim 3 middleware and
callable paradigm.
Install
composer require andrewbreksa/slim-action-helpers
Examples
Action
<?php namespace AndrewBreksa\SlimActionHelpers\Example\Actions; use AndrewBreksa\SlimActionHelpers\AbstractAction; class ExampleAction extends AbstractAction { public function act() { // do some magic here return $this->json([ 'entity' => [ 'email' => 'andrew@andrewbreksa.com', ] ], 201); } } $app->post('/emails', \AndrewBreksa\SlimActionHelpers\Example\Actions\ExampleAction::class);
Middleware
<?php namespace AndrewBreksa\SlimActionHelpers\Example\Middleware; use AndrewBreksa\SlimActionHelpers\AbstractMiddleware; use Psr\Log\LoggerInterface; class RequestLoggingMiddleware extends AbstractMiddleware { /** * Here, if a ResponseInterface is returned, the stack is ejected from, otherwise we continue on and automaically * call $next * @return mixed|void|null */ public function act() { $this->getContainer()->get(LoggerInterface::class)->debug('request', [ 'method' => $this->getRequest()->getMethod(), 'uri' => $this->getRequest()->getUri()->getPath(), 'query' => $this->getRequest()->getQueryParams(), 'headers' => $this->getRequest()->getHeaders() ]); } } $app->add(\AndrewBreksa\SlimActionHelpers\Example\Middleware\RequestLoggingMiddleware::class);
Docs
Eventually I may add very detailed docs, until then read the very simple source. It's literally 4 files.
统计信息
- 总下载量: 4
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-01-30