Toro is a tiny router that lets you develop PHP web applications quickly. It's used by hundreds of hackers at startups, universities, and agencies. Some examples:

"Hello World"

Define a handler that extends ToroHandler. For this example, there will only be one supported HTTP method, GET. Create an instance of ToroApplication passing in an array of route => handler mappings in the constructor. Finally, invoke the serve method.

Toro supports convenient handler methods for routing. The base methods include all HTTP verbs, such as get, post, put, and delete. Additionally, you can also append _xhr to any base, such as get_xhr, to match XHR requests. You can also append _mobile to any base, such as get_mobile, to only match mobile browser requests. Here is an example:

Bob Loblaw's Law Blog

The above is not intended to be a complete blog with database access, security controls, or really anything fancy. Instead, the point is to show how you can model a more substantial application. Pay close attention to get_mobile and post_xhr - they will come in handy.

Toro has a simple callback system called ToroHook. There are four hooks:

before_request after_request before_handler after_handler

Adding a hook pushes the provided function into an array. When a particular hook is fired, all of the functions are fired in the appropriate order. ToroHook was provided by Danillo César de O. Melo.

ToroHook Example

The request callbacks will be fired regardless of the dispatched handler. In the code snippet above, handler hooks are within the respective handler's constructor. Assuming that SomeHandler is executed, the output of the above request echoes will wrap the handler echoes.
Ready to play? Download (zip) or Browse the source (Github). You might need to couch this in your Apache configuration or .htaccess.
Fork me on GitHub