Did your mvc framework, but do not know how best to organize the Router.
1) to Use $_GET parameters /site/?controller=news&action=index
2) to Split the URL into segments:
$routes = explode('/', $_SERVER['REQUEST_URI']);
if ( !empty($routes[2]) ) {
$controllerName = $routes[2]; //controller Name
}
if ( !empty($routes[3]) ) {
$actionName = $routes[3]; //Name of action
}
3) to Prescribe ranting in an array:
$routes = array(
'news' => 'news/index',
'news/([0-9])' => 'news/view'
)
Then the cycle using regular expressions to find matches in $_SERVER['REQUEST_URI'], and accordingly for further action.
1 and 2, in the case of controller and action are determined automatically.
3 I Need to write ranting beforehand, as in laravel Route::get('/', '
[email protected]');
Which way is more flexible and promising?