f3/Fatfree 框架 - 路由第二个参数出错
f3/Fatfree framework - Error on route second param
$f3->route('GET /index.php/@ctrl',
function($f3){
session_start();
if (!isset($_SESSION['user'])) {
echo $f3->get('REDIR_LINK')['LOGIN'];
}
switch ($f3->get('PARAMS.ctrl')) {
case 'admin':
$f3->set('info', array(
'title' => 'Administrator Page'
)
);
echo View::instance()->render('admin.php');
break;
default:
$f3->set('error404', DIR_ASSET.'images/404.jpeg');
echo View::instance()->render('index.php');
break;
}
}
);
但是当我将路线更改为
$f3->route('GET /index.php/@ctrl/@test ~~~~~
我无法仅使用@ctrl 访问该页面,例如/index.php/admin,但我仍然可以访问/index.php/admin/user
您问题的答案可能在 user's guide page:
Another thing: Fat-Free sees GET /brew
as separate and distinct from the route GET /brew/@count
.
我的建议是试试这个:
$f3->route(
array(
'GET /index.php/@ctrl/@test',
'GET /index.php/@ctrl'
),
function($f3) {
...
});
$f3->route('GET /index.php/@ctrl',
function($f3){
session_start();
if (!isset($_SESSION['user'])) {
echo $f3->get('REDIR_LINK')['LOGIN'];
}
switch ($f3->get('PARAMS.ctrl')) {
case 'admin':
$f3->set('info', array(
'title' => 'Administrator Page'
)
);
echo View::instance()->render('admin.php');
break;
default:
$f3->set('error404', DIR_ASSET.'images/404.jpeg');
echo View::instance()->render('index.php');
break;
}
}
);
但是当我将路线更改为
$f3->route('GET /index.php/@ctrl/@test ~~~~~
我无法仅使用@ctrl 访问该页面,例如/index.php/admin,但我仍然可以访问/index.php/admin/user
您问题的答案可能在 user's guide page:
Another thing: Fat-Free sees
GET /brew
as separate and distinct from the routeGET /brew/@count
.
我的建议是试试这个:
$f3->route(
array(
'GET /index.php/@ctrl/@test',
'GET /index.php/@ctrl'
),
function($f3) {
...
});