Skip to content

Instantly share code, notes, and snippets.

@kiall
Created September 12, 2011 17:56
Show Gist options
  • Save kiall/1211914 to your computer and use it in GitHub Desktop.
Save kiall/1211914 to your computer and use it in GitHub Desktop.
<?php
// Fire up a router and add some routes ...
$router = Router::factory();
// This one handles PUT and POST requests
$route_one = Route::factory('tickets_one')
->method(array(
'POST',
'PUT'
))
->defaults(array(
'controller' => 'ticket',
'action' => 'update',
);
// This one handles GET requests
$route_two = Route::factory('tickets_two')
->method(array(
'GET'
))
->defaults(array(
'controller' => 'ticket',
'action' => 'show',
);
$router->add($route_one)->add($route_two);
// Request comes in ..
$request = Request::factory('tickets')->method('PUT');
// execute the request - This goes to Controller_Ticket::action_update();
$response = $router->execute($request);
// Another Request comes in .. This one is not routable...
$request = Request::factory('tickets')->method('DELETE');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment