WARNING: this post is outdated.
Zend Framework has
resource autoloading, so I keep the post for historical reasons only.
Zend Framework (ZF) is the MVC framework. Of course you can use its components in a non-MVC way (and I actually do so in my WP UMapper plugin), but in that case, I suppose, you do not have to worry about models auto-loading.
Frameworks make our coding life easier, and ZF is not an exception – you need very little code to get your application skeleton working. And when it comes to MVC, ZF handles almost everything – your action controllers are triggered, your views are loaded, w/o you having to worry about them. Not the same with models. If you comply to directory layout advised by ZF, you have “models” folder, but framework doesn’t interact with it in any way.
Models are simply classes, containing application logic, and to initialize one of them you have to make sure that:
a) containing directory is withing include_path
b) you require_once the class file before using it
I wanted my models to be available without any additional hassle, so I decided to find a way to auto-load models from within my controller actions.
Read the rest of this entry
design, PHP5, Zend Framework
As I got into Java seriously, I decided to give several Design Patterns books I own yet another try – I have skimmed through GoF’s master-piece number of times, but being a PHP programmer in PHP4 age, I just had no incentive to study patterns any deeper, as there clearly was no option to apply them. PHP5 is better wrt OO-tion but still looks like a toy.
Overall, I don’t understand the whole idea of implementing simple and easy-to-learn language, get popular, and then redesign the language to include all the goodies from “real languages like C/C++, Java”. But that’s topic for another post, I guess
So, now when I have a little more time to experiment with Java, and as it is as object-oriented as one might dream, I wanted to study patterns in details. I plan to post number of articles later this month, but for now, I wanted to capture one (important if you are planning to use UML and Patterns) simple concept – that’s difference between Aggregation and Composition. As simple as it might seem, there quite a lot of people who don’t understand it.
Read the rest of this entry
design, Object-Oriented