I love the elegance of Zend_Controller_Router_Rewrite and the various route classes it 开发者_JAVA百科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?
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.
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.
精彩评论