PHP code example of guglielmopepe / dispatcher

1. Go to this page and download the library: Download guglielmopepe/dispatcher 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/ */

    

guglielmopepe / dispatcher example snippets

 php
$dispatcher = new \Dispatcher\Classes\Handlers\Convention();
$dispatcher->connect(new \Dispatcher\Classes\Handlers\NotFound());


$params = [];

if (isset($_GET['route']))
{
    $params['route'] = $_GET['route'];
}

$route = $dispatcher->handle($params); 

$method = strtolower($_SERVER['REQUEST_METHOD']);

$route->$method();

exit(0);