PHP code example of gears / router

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

    

gears / router example snippets


// Make sure you have composer included
$router = new Gears\Router();
$router->routesPath = '/file/path/to/my/routes';
$router->dispatch();

// At this point execution will not continue. The router will either output
// the results from a route and exit or it will output a 404 and then exit.

Route::get('/', function()
{
	return 'I Am Groot';
});

$router = new Gears\Router();
$router->routesPath = '/file/path/to/my/routes';
$router->notFound = 'Custom 404 HTML';
$router->dispatch();

$router = new Gears\Router();
$router->routesPath = '/file/path/to/my/routes';
$router->exitOnComplete = false;
$router->dispatch();
Route::get('/search/{postcode}', function($postcode){});