Empty GET to AltoRouter


Empty GET to AltoRouter

我试图使用AltoRouter,但我试图遵循其文档,我的问题是$_GET始终为空。

我使用的是Apache,我的。htaccess如下所示:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . index.php [L]

现在这是我的文件取$_GET并制作路由器:

$router->map('GET', '/', 'PageController@getShowHomePage', 'home');
$match = $router->match();
list($controller, $method) = explode("@", $match['target']);
if(is_callable(array($controller, $method))) {
  $object = new $controller();
  call_user_func_array(array($object, $method), array($match['params']));
} else {
  echo "Cannot find $controller -> $method";
  exit();
}

但是我看到它不起作用,因为当我收到$_GET时,它总是空的,我使用print_r($_GET)来查看$_GET内,但返回给我一个空数组。

我尝试使用以下URL,但结果是相同的:

http://localhost/mvc/
http://localhost/mvc/page
http://localhost/mvc/controller
http://localhost/mvc/produto/cadastrar

这是因为在这些url中没有查询(GET)参数。如果你使用say, Get参数将是:http://localhost/mvc?param=1

您可以从$_SERVER

获得更多信息

如果您需要调试帮助,请尝试使用像kint

这样的工具。