我一直在尝试使用 altorouter 获取 Home 控制器的 index() 方法,但无法。我搜索了几个地方,但找不到任何帮助。
这是 index.php
<?php
include 'system/startup.php';
include 'library/AltoRouter.php';
// Router
$router = new AltoRouter();
// Change here before upload
$router->setBasePath('/demo');
$router->map('GET|POST','/', 'home#index', 'home');
// match current request
$match = $router->match();
if( $match && is_callable( $match['target'] ) ) {
call_user_func_array( $match['target'], $match['params'] );
} else {
// no route matched
header( $_SERVER["SERVER_PROTOCOL"] . ' 404 Not Found');
}
目录>控制器目录中的主控制器。
<?php
class home {
public function index() {
echo 'home';
}
}
任何人都可以使用或曾经使用过这个 altorouter 指南吗?
PS我在startup.php文件中有自动加载功能(包含在index.php的顶部)