[ZF]Modular structure

As i have been thinking how to make code maintainable, i thought about modular structure. But as i started to implement it I found this really difficult, as I haven’t found any good articles, guides about this.

Only thing what i found was this blog http://www.atirjavid.com/Zend-Framework-Tutorials/index.html, seems to be really good, but the article hasn’t been finished yet. As i almost got this working as much there is code. Problems come in with model loading. When using model locating in /modules/default/models/DbTable/Users.php then it cant find the model or Zend_Table class.

Last solution what i saw is this, but it makes you say “Isn’t there other way ?”:shifty:

For me, Magento is the perfect example for real implementation of Zend framework.
Totally Modular: Totally Flexible.

Hi, I’ve been into Python lately and I have not looked into ZF at all. I’m just now getting back into ZF so I will finish up the article soon.

I think the problem you are having is because the location ‘/modules/default/models/DbTable/Users.php’ is likely not in your php include path.

When I’m setting up a modular structure with the ZF I like to store all my models in a library folder and have the model class names follow the ZF class naming specs. For instance you could have:

library/MyNamespace/Db/Table/Users.php with the folder structure…


and then the class name would be MyNamespace_Db_Table_Users

With this setup, as long as you include your library folder in the the php include path, you can use the Zend Loader to autoload your model classes!

Hope this helps!

Ok this would be one of the solutions, but the advantage of this is the models are “really” separated. So you store the models and tables similar to this structure.

\—UserService.php (Service layer, business logic)
\—User.php (Zend_Table)

I would think that zend makes things more complicated than they need to be. I haven’t seen large open-source project/product using Zend yet, and if you look around the net, people seem to be having fun and games whenever they try to use zend framework.

Correct me if I’m wrong.

Magento is a large open-source project based on the Zend framework.

Oh ok… well that’s a good one. Thanks for that.

However looking at the list here, it certainly does not give me enough confidence… yet.


I am using now different layout ty from #zftalk



I saw some examples from the Magento code based raised in a recent code review tutorial. There were interesting cases where it seemed classes should have descended from ZF classes/interfaces but did not. Not sure how wide spread that was in the code base or how familiar you are with the details of this projects code. http://www.slideshare.net/sebastian_bergmann/php-code-review-1464932 slides 20-49

I’m pretty familiar with the Magento code, and I have a lot of strong opinions about the code itself - most of them negative. I don’t want to share my opinions about it here because I don’t want to get this thread off-track, but I will sum up my opinions here in one statement: needlessly complex.