Código PHP:
class Router {
/*........etc...*/
public function route() {
$path = $_SERVER['REQUEST_URI'];
if (strstr($path, '?')) {
$path = substr($path, 0, strpos($path, '?'));
}
$path = explode('/', trim($path, '/'));
$this->controller = $path[0];
$this->action = isset($path[1]) ? $path[1] : null;
if (!strlen($controller)) {
$this->controller = 'index';
$this->action = 'index';
}
/*........etc...*/
}
/*........etc...*/
}
Tambien los request http los puedes obtener de $_GET.
Código PHP:
if (!empty($_GET['controller ']))
{
$_GET['controller '];
} else {
$this->controller = 'index';
}
if (!isset($_GET['action']) && !isset($_POST['action']))
{
$this->action = 'index';
} else if(isset($_GET['accion'])) {
$this->accion = $_GET['accion'];
}