Toro is a PHP router for developing RESTful web applications and APIs.
It is designed for minimalists who want to get work done.
"Hello, world"
First, create a handler to support the GET requests.
Then call serve with an array of routes.
That's it.
Routing Basics
Routes are expressed as an associative array.
Stubs, such as :number, :string, and :alpha, can be used instead of common regular expressions.
Of course, regular expressions are still welcome.
RESTful Handlers
Handlers support all HTTP methods, such as GET, POST, PUT, and DELETE.
Appending _xhr matches JSON requests.
If the _xhr method is not implemented, then the given request method is called.
ToroHook
Toro has a simple callback system called ToroHook.
There are five hooks: 404, before_request, after_request, before_handler, and after_handler.
Adding a hook pushes the anonymous function into an array.
When a hook is fired, all of the functions are called sequentially.