Google News
logo
FuelPHP - Interview Questions
What is HTTP verb based routing in FuelPHP?
You can route your URLs to controllers and actions based on the HTTP verb used to call them. This makes it quick and easy to make RESTful controllers.
 
Example :
return array(
    // Routes GET /blog to /blog/all and POST /blog to /blog/create
    'blog' => array(array('GET', new Route('blog/all')), array('POST', new Route('blog/create'))),
);
You can use named parameters and regexes within your URL just like normal :
return array(
    'blog/(:any)' => array(array('GET', new Route('blog/show/$1'))),
);
You can also specify if this route is supported for only http, or only https, by passing false or true as third parameter :
// route only valid if this is an https request
return array(
    'blog/(:any)' => array(array('GET', new Route('blog/show/$1'), true)),
);
Advertisement