Search code examples
phpfat-free-framework

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;
    }
}
);

but when i change the route to

$f3->route('GET /index.php/@ctrl/@test ~~~~~

i can't access the page with only @ctrl, like /index.php/admin, but i still have a access to /index.php/admin/user


Solution

  • The answer to your question is probably on user's guide page:

    Another thing: Fat-Free sees GET /brew as separate and distinct from the route GET /brew/@count.

    My advice would be to try this:

    $f3->route( 
        array(
            'GET /index.php/@ctrl/@test', 
            'GET /index.php/@ctrl'
        ),
        function($f3) { 
            ... 
        });