This is directed at Martel (since he's the route guy), but I thought I'd plug the list to see what you people have to say.
(Disclosure: This makes a few references to rails, but I am not a rails developer, and I couldn't code ruby for my life. So don't hate! I just look to their framework for guidance, as they have this stuff down to an art.) Basically what I'd like to do is have routes have some form of relationship between routes and some form of "resource" (in rails they are models). For example, the following routes: user_path = /users/:id users_path = /users post_path = /posts/:id posts_path = /posts tag_path = /tags/:id tags_path = /tags edit_tag_path = /tag/:id/edit Now, in rails this is called "nesting". I guess this is what chaining will try to implement: user_tags_path = /user/:user_id/tags user_tag_path = /user/:user_id/tags/:id edit_user_tag_path = /user/:user_id/tags/:id/edit post_tags_path = /post/:post_id/tags post_tag_path = /post/:post_id/tags/:id edit_post_tag_path = /post/:post_id/tags/:id/edit All of these (with the exception of user(s)_path and post(s)_path) map to a TagsController. This keeps things DRY. But when you hit the view files you will immediately stumble into the problem of "what route am I currently in, and how do I make a link with the same level of nesting? And how do I know what params it requires (user_id / post_id)?" With something as generic as tags, it's possible that everything in your app could be taggable. That could make for a lot of IF statements in your controller, or an enormous switch, to pre-define view variables to make these routes. Here is a plugin (if you can read ruby) which solves this problem in rails: http://blog.ardes.com/archives/2007/9 Another issue I have with the routers is that there is no simplified REST-like support. Say I have a UserController. It would be nice to just addRoute(new Zend_Controller_Router_Route_Rest('user')); and have it make all seven routes <http://topfunky.com/clients/peepcode/REST-cheatsheet.pdf> for me, with full GET/POST/PUT/DELETE support on match() (ie it won't route to destroyAction if the request isnt a DELETE request). The problem is within addRoute it can only accept one route, not seven, and a construct can only return one instance (itself) anyway. Perhaps a factory method is in order (didn't there used to be one?). Also, as of right now the config files for doing such a task get really big really quick; it is extremely verbose. Something like this<http://github.com/trevorturk/el-dorado/tree/afdcf2460a17c6163224d59ff8e38d4a4a6b7942/config/routes.rb> would easily take 1,000+ lines to achieve in a current config file format. A buddy and I made a controller plugin (no, that's not the right place for it, it's a hack) viewable here: http://restfulphp.googlecode.com/svn/trunk/library/Rest/Controller/Plugin/Routes.php Which accepts XML configs close to the same format as rails' routes.rb: http://code.google.com/p/restfulphp/source/browse/trunk/demo/application/configs/routes.xml?r=32 Beware; I wasn't joking when I called it a hack. But you get the idea of what it's doing. And yea, I've seen the Zend_Controller_Router_Route_Rest proposal, but it doesn't really do it right, and the problem extends beyond just a route, it trickles down into the router, the controller, and the view helpers... Just some thoughts, does anyone else have any input? Jason Eisenmenger
