PHP code example of joanrodas / plubo-routes

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

    

joanrodas / plubo-routes example snippets


PluboRoutes\RoutesProcessor::init();

add_filter( 'plubo/routes', array($this, 'add_routes') );
public function add_routes( $routes ) {
    //Your routes
    return $routes;
}

use PluboRoutes\Route\Route;

add_filter( 'plubo/routes', array($this, 'add_routes') );
public function add_routes( $routes ) {
    $routes[] = new Route('clients/list', 'template_name');

    //SAGE 10 example
    $routes[] = new Route(
        'dashboard/{subpage:slug}',
        function($matches) {
            $subpage = 'dashboard/' . $matches['subpage'];
            return locate_template( app('sage.finder')->locate($subpage) );
        },
        [
            'name' => 'my-route'
        ]
    );
    return $routes;
}

add_filter( 'plubo/template', function($template) {
    return app('sage.finder')->locate($template);
});

add_action('plubo/route_{route_name}', function($matches) {
    //Do something
});