views:

313

answers:

5

I've been getting to grips with MVC (in PHP) by way of Zend. My understanding of the Zend Framework is that each type of user request maps to a specific controller (which in turn may or may not map to a model), and each action maps to a view. I've noticed the same pattern in Codeigniter and Kohana, and to some extent also in Symfony. Effectively, the URL maps thus:

www.domain.com/index.php/CONTROLLER/ACTION/...additional parameters...

Is this always the case with MVC? In what way is this different from Page Controller as a design pattern?

A: 

I think the primary difference is that with the Page Controller pattern, you have a separate file for each page of your website. In a typical implementation of MVC in PHP, you can group common actions together in a single controller. Also, the typical MVC implementation in PHP support custom routing allowing you to create custom maps to controllers/actions without the need of using http server rewrites.

Chris Gutierrez
+1  A: 

Zend Framework uses Two Step View. It's very similar to MVC. As you can see, theres not so much correspondence between the architecture and the url mapping.
If you want to learn about likely architectures, read PoEAA by Martin Fowler.

erenon
ZF could be used with an MVC pattern and for the View part it uses a 2 step view pattern
Nicky De Maeyer
A: 

1-"Is this always the case with MVC?

www.domain.com/index.php/CONTROLLER/ACTION/...additional parameters..."

No its not always case you can extend the routing to be Domain based (as example ) :

DOMAIN.TLD/USER to be USER.DOMAIN.TLD

2-I think but I am not 100% sure that the page controller is subset of in MVC Pattern I mean Page Controller = the Controller ONLY !!!

tawfekov
A: 

Yeah, it's the most common usage of uris. But there's noting saying that you can't use the MVC pattern with (ir)regular uris. A uri like http://www.domain.tld/?controller=home&action=posts or even http://www.google.com/search?hl=en&source=hp&q=MVC would do just fine.

MVC is all about how you structure yourlayers and is not reflected in the uri.

alexn
A: 

My answer here may be able to help you (or anyone else in this situation since this is set to Answered already).

manbeardpig