Page 1 of 1
writing an effective router/dispatcher for mvc pattern ??
Posted: Thu Jan 24, 2008 5:12 am
by PHPycho
hello forums !!
I am trying to make an router/dispatcher for oo mvc pattern.
I would like to have one default router pattern ie controller/method/id and other is customized one
for example
Code: Select all
http://yoursite.com/controller/method/id/params => $controller->method($id[, $params])(general)
http://yoursite.com/admin/controller/method/id/params => $controller->admin_method($id[, $params]) (customized)
Can anybody provide good suggestions/samples in dispatching such method.
Note: dispatching method should work both for url rewriting turned on or off by changing some flags.
Thanks in advance for your valueable suggestions.
Re: writing an effective router/dispatcher for mvc pattern ??
Posted: Thu Jan 24, 2008 5:36 am
by ynwa
Re: writing an effective router/dispatcher for mvc pattern ??
Posted: Fri Jan 25, 2008 2:18 am
by PHPycho
Knock Knock... Can anybody come with better ideas
Re: writing an effective router/dispatcher for mvc pattern ??
Posted: Fri Jan 25, 2008 2:26 am
by Christopher
You are asking a couple of huge design questions. The article above is a good intro to Dispatchers. You can take a look at code like Horde Routes for a router. Are you looking for simple or complex. You did not mention a Front Controller, but that is implicit in the discussion. And, Front Controller and Routers are really separate from MVC. The dispatched Action Controller is really the MVC part in modern architectures.
Given that it is such a broad subject ... is there something specific you would like to start with?
Re: writing an effective router/dispatcher for mvc pattern ??
Posted: Fri Jan 25, 2008 4:06 am
by s.dot
This exact question is what has stopped me in my progress on going totally OOP.
Of course, I don't mean literally stopped. I still read tons of articles and write practice code to experience different situations with what I already know.
Re: writing an effective router/dispatcher for mvc pattern ??
Posted: Fri Jan 25, 2008 1:59 pm
by Kieran Huggins
I've been swayed to the front controller camp, and also away from mod_rewrite. I'm still "finding myself" as it were when it comes to routing in PHP, but I've been thinking a lot more about using regex expressions. I think symfony uses this approach, so that might be a good starting place for inspiration.
Re: writing an effective router/dispatcher for mvc pattern ??
Posted: Fri Jan 25, 2008 2:18 pm
by Oren
PHPycho wrote:Knock Knock... Can anybody come with better ideas
What's wrong with this one?