PHP code example of devpontes / route

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

    

devpontes / route example snippets




// Define routes
$routes = [
    ['/','Home@index'],
    ['/about', 'About@index'],
    ['/contact', 'Contact@index'],
    ['/blog/{artigo}', 'Blog@index'],
];

$namespace = "App\Controller";
$route = new \DevPontes\Route\Route($routes);
$route->namespace($namespace);
$route->run();

// Redirect
if ($route->fail()) {
    header('Location: /not-found');
}