1. Go to this page and download the library: Download hulotte/routing 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/ */
hulotte / routing example snippets
$dispatcher = new \Hulotte\Routing\RouteDispatcher();
// $request is an object that implements ServerRequestInterface
// Response is an object that implements ResponseInterface
$route = $dispatcher->match($request);
if ($route === null) {
return new Response(404, [], 'Not found !');
}
$callable = $route->getCallable();
return new Response(200, [], call_user_func_array($callable, [$request]));
class MyClass
{
public function __invoke(ServerRequestInterface $request)
{
return 'Hello World';
}
}
Return New Response(200, [], call_user_func_array(new MyClass(), [$request]));
class MyClass
{
public function myMethod(ServerRequestInterface $request)
{
return 'Hello World';
}
}
Return New Response(200, [], call_user_func_array([new MyClass(), 'myMethod'], [$request]));
new \Hulotte\Middlewares\RoutingMiddleware($dispatcher);
$routingMiddleware = new \Hulotte\Middlewares\RoutingMiddleware($dispatcher);
$routingMiddleware->setNotFoundCallable(function(){
return 'Oups, not found !';
});
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.