1. Go to this page and download the library: Download bulldog/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/ */
bulldog / router example snippets
use Bulldog\Router;
use Zend\Diactoros\ServerRequest;
use Zend\Diactoros\ServerRequestFactory;
// You'll usually use the line below, but to demonstrate, we will create our own request.
// $request = ServerRequestFactory::fromGlobals();
$request = new ServerRequest([], [], '/', 'GET');
$router = new Router;
$router->addRoute('get', '/', 'callable');
$router->run($request);
echo $router->handler();
// callable
var_dump($router->vars());
// array(0) {
// }
use Bulldog\Router;
use Zend\Diactoros\ServerRequest;
use Zend\Diactoros\ServerRequestFactory;
// You'll usually use the line below, but to demonstrate, we will create our own request.
// $request = ServerRequestFactory::fromGlobals();
$request = new ServerRequest([], [], '/user/1', 'GET');
$router = new Router;
$router->addRoute('get', '/user/{id}', 'callable');
$router->run($request);
echo $router->handler();
// callable
var_dump($router->vars());
// array(1) {
// 'id' =>
// string(1) "1"
// }
bash
php-cs-fixer fix ./src
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.