Google News
logo
FuelPHP - Interview Questions
What is Inline routes in FuelPHP?
A route does not have to resolve to a controller method. FuelPHP also supports inline routes, which are defined as a Closure that replaces the controller method. Like controller methods, inline routes MUST return a Response object, either by forging one manually, or as the result of executing a forged Request.
 
Example route :
return array(
    'secret/mystuff' => function () {
        // this route only works in development
        if (\Fuel::$env == \Fuel::DEVELOPMENT)
        {
            return \Request::forge('secret/mystuff/keepout', false)->execute();
        }
        else
        {
            throw new HttpNotFoundException('This page is only accessable in development.');
        }
};
Advertisement