Simple routing to the simple actions.
It is simpler than you think:
<?php
use Router\Router;
$router = new Router();
// set default data
$router->setDefaultModule('index');
$router->setDefaultController('index');
$router->setDefaultAction('index');
// set first track
// you can always set your request type,
// so you can define few the same url addresses with different request
$router->add(
'/',
[
'module' => 'FirstNamespace\Second\Third',
'controller' => 'Controller',
'action' => 'action'
],
[
'method' => 'get|post'
]
);
//You can always set data from url address
// param1 values will change on :param values from url,
// if the value meets the criteria.
$router->add(
'/admin/controllers/user/show/:param',
[
'module' => 'Lib\Controllers',
'controller' => 'user',
'action' => 'show',
'param1' => 1
],
[
'method' => 'get'
]
);
// It gets data to variable
// For example we can transfer this to PageController or FrontController.
$route = $router->resolve();