PHP code example of lesichkovm / php-autoroute

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

    

lesichkovm / php-autoroute example snippets


autoroute(parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH));

// 1. Get the current route
$route = isset($_REQUEST['route']) ? $_REQUEST['route'] : '';

// 2. Autoroute
try {
    autoroute($route, [
        'default_method' => 'index',
        'default_controller' => 'Guest',
        'default_namespace' => 'App\\Controllers',
        'use_request_method' => true,
    ]);
} catch (ReflectionException $re) {
    // Page not found
    die('Not found:' . $re->controller . '@' . $re->method);
} catch (Exception $e) {
    // Other non routing related exception
    // Deal with exception (i.e. send yourself a mail)
    die('Exception occurred');
}
bash
composer 
json
   "repositories": [
        {
            "type": "vcs",
            "url": "https://github.com/lesichkovm/php-autoroute.git"
        }
    ],
    "