1. Go to this page and download the library: Download polus/adr 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/ */
polus / adr example snippets
use Aura\Payload_Interface\PayloadInterface;use Aura\Router\RouterContainer;use Http\Factory\Diactoros\ResponseFactory;use Http\Factory\Diactoros\ServerRequestFactory;use Polus\Adr\Actions\AbstractDomainAction;use Polus\Adr\Adr;use Polus\Adr\Interfaces\Resolver;use Polus\Adr\ResponseHandler\HttpResponseHandler;use Polus\Router\AuraRouter\RouterCollection;use Polus\Router\RouterMiddleware;use Psr\Http\Message\ResponseInterface;use Psr\Http\Message\ServerRequestInterface;
$responseFactory = new \Http\Factory\Diactoros\ResponseFactory();
$routerContainer = new RouterContainer();
$routerCollection = new RouterCollection($routerContainer->getMap());
$routerDispatcher = new Polus\Router\AuraRouter\Dispatcher($routerContainer);
$actionResolver = new class implements Resolver {
//..
};
$adr = new Adr(
new ResponseFactory(),
$actionResolver,
$routerCollection,
new HttpResponseHandler(),
new \Polus\MiddlewareDispatcher\Factory(
new \Polus\MiddlewareDispatcher\Relay\Dispatcher($responseFactory),
[
new RouterMiddleware($routerDispatcher),
//More psr-15 middlewares
]
)
);
//Define routes and actions
class Responder implements Responder
{
public function __invoke(
ServerRequestInterface $request,
ResponseInterface $response,
PayloadInterface $payload
): ResponseInterface {
$response->getBody()->write("Index responder\n");
return $response;
}
}
$adr->get('/', new class extends AbstractDomainAction {
protected $responder = Responder::class;
});
//Run application
$factory = new ServerRequestFactory();
$adr->run($factory->createServerRequestFromArray($_SERVER));
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.