1. Go to this page and download the library: Download bitexpert/adrenaline 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/ */
bitexpert / adrenaline example snippets
use bitExpert\Adrenaline\Adrenaline;
use Zend\Diactoros\ServerRequestFactory;
use Zend\Diactoros\Response;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Message\ResponseInterface;
$adrenaline = new Adrenaline();
$adrenaline->get('home', '/', function (ServerRequestInterface $request, ResponseInterface $response) {
$response->getBody()->rewind();
$response->getBody()->write('Home');
return $response;
});
$request = ServerRequestFactory::fromGlobals();
$response = new Response();
$adrenaline($request, $response);
$customActionResolver = new MyCustomActionResolver();
$adrenaline = new Adrenaline([$customActionResolver]);
$customResponderResolver = new MyCustomResponderResolver();
$adrenaline = new Adrenaline([], [$customResponderResolver]);
$customRouter = new MyCustomRouter();
$adrenaline = new Adrenaline([], [], $customRouter);
$adrenaline = new Adrenaline();
$adrenaline->setDefaultRouteClass(MyRoute::class);
$myMiddleware = function (ServerRequestInterface $request, ResponseInterface $response, callable $next = null) {
};
$adrenaline->beforeRouting($myMiddleware) //Middleware piped before routing middleware
$adrenaline->beforeResolveAction($myMiddleware) //Middleware piped before action resolver middleware
$adrenaline->beforeExecuteAction($myMiddleware) //Middleware piped before action executor middleware
$adrenaline->beforeResolveResponder($myMiddleware) //Middleware piped before responder resolver middleware
$adrenaline->beforeExecuteResponder($myMiddleware) //Middleware piped before responder executor middleware
$adrenaline->beforeEmit($myMiddleware) //Middleware piped before emitter
// simple closure
$adrenaline->setErrorHandler(function (ServerRequestInterface $request, ResponseInterface $response, $err) {
return $response->withStatus(500);
});
// class which implements __invoke with same signature as above
$adrenaline->setErrorHandler(new MyCustomErrorHandlerClass());
$adrenaline->setErrorHandler(new ErrorHandler(new Response(), function ($err, ServerRequestInterface $request, ResponseInterface $response) {
return $response->withStatus(500);
});
// class which implements __invoke with same signature as above
$adrenaline->setErrorHandler(new ErrorHandler(new Response(), new MyErrorResponseGenerator());
/** @var \Interop\Container\ContainerInterface $container */
$actionResolver = new \bitExpert\Adroit\Action\Resolver\ContainerActionResolver($container);
/** @var \Interop\Container\ContainerInterface $container */
$responderResolver = new \bitExpert\Adroit\Responder\Resolver\ContainerAwareResponderResolver($container);
// Adrenaline will use your containers for resolving actions and responders
$adrenaline = new Adrenaline([$actionResolver], [$responderResolver]);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.