PHP code example of dlpwd / router

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

    

dlpwd / router example snippets


$router = new \dlpwd\router\Router();

$router->get('/', '\\dlpwd\\sample\\controller\\dashboard::renderDashboard');
$router->get('/login', '\\dlpwd\\sample\\controller\\login::showLoginForm');
$router->post('/login', '\\dlpwd\sample\\controller\\login::processLogin');
$router->get('/page/{friendlyUrl}', '\\dlpwd\\sample\\controller\\page::showPage');

$router->resolve();

Router::get($_url, $_handler);
Router::post($_url, $_handler);
Router::delete($_url, $_handler);
Router::addRoute($_method, $_url, $_handler);

Router::resolve($_url, $_method);