I enjoy simplicity, in everything. Unnecessary complexity is evil. Have a look at my WordPress plugins.

AltoRouter, another PHP Routing class.

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)
  • Wildcards
  • Parameter types
  • Custom regexes, if the built-in regular expressions aren’t suited for your project

AltoRouter is hosted on GitHub and also available as a Composer package from Packagist. Feel free to take a look at the code or contribute to the routing class.

Update (April 2014): Tyler Longren (a contributor to the project) wrote a great “getting started” post for AltoRouter.

Share this post: on Twitter on Facebook

One Response to “AltoRouter, another PHP Routing class.”

Leave a Reply