PHP code example of cowshed / router

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

    

cowshed / router example snippets



add_action( 'init', function () {
    $router = new Router();
    $router->route( [
        'name'     => 'home', // slug my-custom-route
        'template' => 'views/template-home.blade.php', // template path
        'ref'      => 'home', // reference for URL fetching
    ] )->route( [
        'name'     => 'about us',
        'template' => 'views/template-about.blade.php',
        'ref'      => 'about',
    ] )->bind();
} );

 

\Cowshed\Router\Router::url('test')