views:

309

answers:

2

I love the elegance of Zend_Controller_Router_Rewrite and the various route classes it uses.

I'd like to write a very similar routing system as a standalone component so I can translate URLs into a set of parameters and assemble them back again. The idea is to use them to select, say, an URL normalization handler on a per-path basis.

I have considered extending the actual Zend Controller Route classes to make my own. But, these classes seem very deeply routed (if you'd excuse the pun) in the domain language of the Zend MVC.

Do you know of a standalone routing package/set of classes available to use in my project?

Is the zend router an example of any particular design pattern I could use if i write my own?

Do you have any tips on writing a URI router?

A: 

i hope i do not mis-understand your question.

i haven't used Zend_Controller_Router, but codeigniter and cakephp router explode a url parameter by '/', and map them to different controllers and methods, which, i think, is not difficult to implement one from scratch.

joetsuihk
Thanks. That's a perfectly reasonable answer. However, I'm looking to use it to route a mishmash of slightly more complex, legacy, urls. Using various strategies and combinations of rules. The Zend Router can do these things. In the end, I might just go thru their code and use it as a blue print. Was just putting the feelers out beofre starting on it in case the solution could be handed to me on a plate tho.
JW
A: 

Check out the URL Router in the Alloy PHP Framework:
http://alloyframework.org/manual/url-router/

There is a specific heading about using it outside the framework as a standalone library, and IMHO it is a much more elegant solution than Zend_Controller_Router_Rewrite.

Vance Lucas
Thanks. I had never heard of Alloy. I love its philosophy "Explicit over Implicit". and "OOP...that isn't focused on trying to be like Java" - nice. I am looking into it.
JW
Pity, looks good but, I have just noticed it is min PHP 5.3. I'm trying to lick a legacy app into shape as a pre-cursor to making it 5.3-ready. So, will have to wait til then before I can use it. I like the HMVC architecture - its all new to me.
JW