1. Go to this page and download the library: Download middlewares/aura-router 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/ */
middlewares / aura-router example snippets
//Create the router
$router = new Aura\Router\RouterContainer();
$map = $router->getMap();
$map->get('hello', '/hello/{name}', function ($request) {
//The route parameters are stored as attributes
$name = $request->getAttribute('name');
//You can echo the output (it will be captured and writted into the body)
echo sprintf('Hello %s', $name);
//Or return a string
return sprintf('Hello %s', $name);
//Or return a response
return new Response();
});
$dispatcher = new Dispatcher([
new Middlewares\AuraRouter($router),
new Middlewares\RequestHandler()
]);
$response = $dispatcher->dispatch(new ServerRequest('/hello/world'));
$routerContainer = new Aura\Router\RouterContainer();
$route = new Middlewares\AuraRouter($routerContainer);
$routerContainer = new Aura\Router\RouterContainer();
$responseFactory = new MyOwnResponseFactory();
$route = new Middlewares\AuraRouter($routerContainer, $responseFactory);
$dispatcher = new Dispatcher([
//Save the route handler in an attribute called "route"
(new Middlewares\AuraRouter($routerContainer))->attribute('route'),
//Execute the route handler
(new Middlewares\RequestHandler())->attribute('route')
]);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.