Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/geggleto/helper_classes
https://github.com/geggleto/helper_classes
Last synced: 5 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/geggleto/helper_classes
- Owner: geggleto
- License: mit
- Created: 2015-12-21T13:29:37.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2015-12-23T16:27:06.000Z (almost 9 years ago)
- Last Synced: 2024-04-02T23:44:45.558Z (8 months ago)
- Language: PHP
- Size: 13.7 KB
- Stars: 1
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Helper Classes
Slim 3 is a very different beast than Slim 2.
These Helper classes will help you migrate or start a new project in Slim 3.
## BaseAction Example```php
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;
}}
```
## Setup/Config
None!## Usage
HelloWorldAction
```
$app->get('/hello/world', '\Your\Namespace\HelloWorldAction');
```HellWorldMiddleware
```
$app->add('\Your\Namespace\HelloWorldMiddleware');
```## Container
These classes hold a container instance so you can receive dependencies via $this, just like in Slim 2.