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


$routes = [
    ['/', 'Home@index'],
    ['/blog', 'Blog@index'],
    ['/contato', 'Contact@index'],
    ['/contato/{id}', 'Contact@index'],
    ['/not-found/404', 'Notfound@index'],
];

$url = $_GET['url'];

$url = $_SERVER['REQUEST_URI'];

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

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

$route->setStrictMode(true);