PHP Zend Framework – Why is Zend Framework So Complicated?

PHPzend-framework

I am web developer and have experience of developing several web applications in PHP. I have an idea of developing a product for myself and decided to use a MVC based framework because I really like the idea of MVC and how one can easily manage and modify the application without any difficulty.

I chose Zend Framework and it seems more difficult than learning a new programming language. There are so many things going at one time even to run a small application.

Similarly the idea of routing is very complex as it is new for a core programmer. I know that the guys here read thousand of such questions like one I am asking but I am not looking to learn Zend Framework overnight. I am willing to give as much time as it needs but until now it's making no sense to me. There are thousand of classes in the Zend library, but how would a noob know where to use a specfic class and how to use it? I am still finding it very difficult to understand the bootstrap of Zend Framework and its mapping. I read the manual, follow it and things start working but I really don't exactly how they are actually happening.

I also still have no clue how models, views and controllers work together and how to plan an application in Zend Framework. When it comes to core php I exactly have the idea in my mind what to do and than easily translate them in code but in Zend Framework I don't know how to translate my idea.

Best Answer

Zend Framework is hard. It wasn't built as an entry level framework, knowledge of the concepts involved is assumed1. That said, the first requirement for Zend Framework 2.0 is to make it a little bit easier:

Ease the learning curve

In late 2009, we did a survey of framework users to determine what they use, what environments they use, and what their needs are. The top issue, bar none, was the difficulty of learning the framework. Some of these issues include:

  • Difficulty in the "first hour" with the framework.
  • Uncertainty about the "next steps" following the quick start.
  • Inconsistent APIs in the source code itself. One component may use "plugins," another "helpers," and yet another "filters."
  • Uncertainty about where extension points exist, and how to program for them.
  • Confusion over whether they can use Zend Framework only as an MVC stack or as individual components.

So it's not just you, it's hard for everyone - read the whole wiki page, there are quite a few things that are identified as unnecessarily complex. But even if the above requirement is fulfilled, still it won't become an entry level framework, meaning that it's not a framework you should be learning on, but one that you should be using when you've actually understood the concepts involved.

Since you are still learning, it would be a lot more valuable to build your own MVC architecture. Rasmus Lerdorf's notorious2 "The no-framework PHP MVC framework" blog post gives a very simple and clean example of MVC through procedural PHP, without any framework or other third party library involved.

But if you really want to learn with a framework, you should consider a micro framework instead of a full blown one. Slim has a very small, clean and thoroughly tested code base and it should be ideal for learning. I haven't played around with any other micro framework, you should do your own research and decide which one is better for you.

And for a quick and dirty introduction to routing, see my answer to this question. It's not a very hard concept to grasp, but Zend Framework does make it look like a lot more than it actually is.

1 The best description I've read for ZF is that's it's a framework building framework, not an application framework. It's raw power and extreme list of features aren't suitable for small to medium websites. Unfortunately can't really find where I read that.

2 Read disclaimer at the top of the blog post.


Update, inspired by @Karpie's comment:

A framework is not supposed to be hard, the whole point of a framework is to make things easier. It's possible that even with a firm grasp of the concepts involved, ZF is not a good fit for you.

There are a lot of subjective factors involved when choosing a framework, and unless every other framework lacks functionality you absolutely need - and can't write on your own, you should avoid ZF and use a framework that feels more natural to you.

If you know the concepts, the framework shouldn't be getting in the way.

Related Topic