A few months earlier I blogged about developing PHP Router, a PHP5.3+ routing class with support for REST routing and reversed routing.
Well, last week I came across klein.php, a lightweight PHP router developed by Chris O’Hara. I particularly liked the fact that it’s pretty easy to specify certain type restrictions for your URL parameters so I decided to create my own version of klein.php. The aim was to create something that worked in a similar way as my own PHP Router class, but with the easiness of klein.php.
So, here it is: AltoRouter, a tiny routing class which will help you in your future PHP projects.
- Usage of different HTTP Methods
- Dynamic routing, which lets you capture certain URL segments as parameters
- REST Routing
- Reversed routing (generating URLs from route names with parameter values)
- Parameter types
- Custom regexes, if the built-in regular expressions aren't suited for your project
Update (October 2014): AltoRouter now has its own site containing detailed usage instructions.