I've been studying Zend Framework's MVC for a few weeks, and am having a really, really difficult time with it. I'm new to OOP, but I understand OOP in PHP without too much difficulty; I understand how to use some of the packages in Zend's library, etc. I understand interfaces, abstract classes, composition, etc. etc. etc. I understand MVC on a high-level, but does anyone know if/where there is a resource that describes the MVC implementation on the ground level? Or should I just stop worrying about it and try to ignore the mechanics of the implementation initially?

I've been working through several books and resources online on the MVC implementation, and it seems extremely complex. (Also, earlier versions had different implementations, making it slightly more confusing to understand). The tack I'm trying to take is what I usually do when I want to understand something: go through it line by line and follow the logic around until it all becomes clear.

After trying this over and over (and not getting very far), I'm wondering if I'm not going about this the wrong way. After all, OOP is all about not worrying about the implementation, right? I mean, I hear myself saying that and I cringe. I don't like not knowing what's going on, but I'm finding this extremely complicated, and I would really like to get to the part where I actually create something.

From what I can tell, though, Zend is incredibly well-conceived (perhaps too thoroughly well-conceived, if that makes any sense). All of the i's are dotted and t's crossed, which makes it very difficult to dig through (lots of abstract classes, some interfaces, objects being passed here and there, etc.--hard to follow). But the books and sites I've looked at don't go into significant detail about how the process works, only high level descriptions, or they are outdated and using an different implementation. I would prefer to understand it at a lower level.

2 Answers 2


I'm not sure what exactly are you looking for - the high-level overview is the description of the implementation. The low-level is the implementation itself.

I'll try to recap it shortly -

  1. A request arrives and is intercepted by the front controller.
  2. The request is encapsulated in a request object. (Default is Zend_Controller_Request_Http)
  3. A router is used to parse the request URI to determine which controller + action will be invoked. (Default is Zend_Controller_Router_Rewrite)
  4. The front controller starts the dispatch loop ($router -> route() with the current route in the loop).
  5. Pre dispatch hooks are invoked (init() then preDispatch() in Zend_Controller_Action, user defined).
  6. Controller action is invoked (user defined).
  7. Post dispatch hooks are invoked (postDispatch() in Zend_Controller_Action, user defined).
  8. If more actions are in the loop queue, go back to 4 (routes can be added to the queue during the dispatch loop).
  9. Response is sent back to client (default is Zend_Controller_Response_Http).

You can watch this process in the Zend_Controller_Front::dispatch() method for the implementation specifics.

  • the "implementation specifics" is what I meant by "describes...the ground level." I've seen this high-level description several times, and I understand it (not much to be confused about). But I couldn't find the implementation (Zend_Controller_Front::dispatch()--thank you for the lead; I'll check it out). A walk-through, class-by-class, method-by-method, from index.php onward would be really helpful. Does that exist?
    – user25791
    Commented Jun 5, 2011 at 14:38
  • For that you would have to read the actual code. It might be complex by PHP standards, but it's really not very complex. I can add the class and method names to the process I described if that would help Commented Jun 5, 2011 at 14:47
  • It's maybe only complex to me- but like I said I'm new to OOP. I definitely want to read the actual code. Yes, please add the class and method names, and I will happily go through the code. I've been trying to do that already, but I guess I'm just not familiar enough with MVC or OOP to do that successfully without a little more guidance. I appreciate it.
    – user25791
    Commented Jun 5, 2011 at 14:56
  • added involved classes and methods Commented Jun 6, 2011 at 0:09
  • I found that the examining the source code for the methods Zend_Controller_Front::dispatch() and Zend_Controller_Dispatcher_Standard::dispatch() helped me a lot. Commented Jun 6, 2011 at 2:32

True knowledge, like friendship, is only attainable through the passage of time. I suspect that you will not be able to front load the entire Zend MVC concept, nor will it be of much use to you.

I'm working on a fairly large ZF app at the moment, and no one coder on the team has a "total" picture of the system, let alone the framework. One focuses on making usable components, and then assemble those components into increasingly complex but high level structures. Sometimes, this assemblage produces emergent behaviour - if it's undesirable, it's a bug, otherwise it's a feature!

My advice, having worked on a few ZF apps now, is to focus on using the framework to satisfy the goals of the project. You will learn the intricacies of ZF over time. As you've rightly observed, the whole point of a OOP is to hide the specifics of the implementation.

Sure, you should (and almost certainly will) take a look under the bonnet if only out of academic interest - but in principle you shouldn't need to in order to drive the car...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.