PHP code example of andrewbreksa / slim-action-helpers
1. Go to this page and download the library: Download andrewbreksa/slim-action-helpers library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
andrewbreksa / slim-action-helpers example snippets
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' => '[email protected]',
]
], 201);
}
}
$app->post('/emails', \AndrewBreksa\SlimActionHelpers\Example\Actions\ExampleAction::class);
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);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.