Horde/Routes 0.4 Released
-
Horde/Routes 0.4 has been released. Horde/Routes is a URL mapping system for PHP 5 that provides classes for mapping URLs to the controllers and actions of an MVC system. Learn more at the project website or this presentation.
This version includes a new utility class,
Horde_Routes_Printer, a debugging aid that can print out a summary of all routes that are connected to a mapper. It is available through a convenience method fromHorde_Routes_Utils:$map = new Horde_Routes_Mapper(); $map->connect('post', ':title', array('controller'=>'posts','action'=>'show')); $map->connect('feeds', 'feeds/:format', array('controller'=>'feeds')); $map->connect(':controller/:action/:id'); $map->utils->printRoutes();
This will cause the following information to be printed to
php://output:post /:title {:controller=>"posts", :action=>"show"} feeds /feeds/:format {:controller=>"feeds", :action=>"index"} /:controller/:action/:idYou’ll see above that the name of the route (if any) is shown, the route path, and the default values for the route. If a route only matches for a certain HTTP method, this will be shown as well. It’s handy when you have a large number of routes, or resource routes.
If you’d like the debug output to go somewhere else, pass a stream resource as the first argument to
printRoutes(). The output is formatted similarly to therake routescommand from Rails. Although the notation is a little unusual for PHP, it’s compact and readable. SeeHorde_Routes_Printerif you’d like to modify the format.Since it’s release, we’re received a good amount of positive feedback on Horde/Routes. It is now being shared by the upcoming Horde 4 (Rampage), the Seagull framework, and a few others. Check out the integration guide for how to add it to your project.

2 comments
comment by Josh Davis 4 Mar 09
Horde/Routes really looks good so far, I hope it will see widespread adoption.
I’m currently evaluating my own needs to see if I could benefit from using Horde/Routes rather than rolling my own router (I’m not even sure I need a router at this point) so I’ve downloaded Horde/Routes and I started poking around the source code to see how complex it was. I have noticed a couple of routines that could be simplified/streamlined, and a potential bug, where can we submit those? I have an obsessive-compulsive tendency to benchmark/optimize any code I see, do you plan on accepting patches?
Wrt that potential bug, it’s in Route.php line ~188-189. There’s an isset($kargs['_absolute']) followed by unset($kargs['absolute']). One has an underscore, the other doesn’t.
comment by Mike Naberezny 4 Mar 09
Josh,
You can submit bug reports or patches on bugs.horde.org. Please select the “Horde Framework Packages” queue.
Thanks for reporting the issue with unset(). It has been fixed on Git master.
Regards,
Mike
Sorry, the comment form is closed at this time.