42

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.

3
  • 10
    If you're new to MVC, implement an MVC scaffold yourself before using any of the full-blown ones -- they're not good for learning.
    – treecoder
    Commented Dec 6, 2011 at 5:33
  • 2
    @greengit that's what I did!
    – Kyle
    Commented Dec 6, 2011 at 5:39
  • Zend Framework is not hard, it requires a bit of time to learn, due to bad documentation, but I can ensure you, that it is a very powerful framework. We've build big enterprise software on ZF2, and the flexibility on configuration is extraordinary in ZF.
    – albanx
    Commented Aug 5, 2016 at 9:09

7 Answers 7

38

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.

4
  • 3
    Even with knowledge of the concepts, it's damn hard to get into, and to be honest I don't think it's worth the effort. The documentation is often wrong, examples on the web after usually out of date, the IRC support channel is generally dead, and from what I've seen there's no other place to get support. Commented Dec 6, 2011 at 7:16
  • @Karpie I don't find it that hard, to be honest. But it's kind of idiomatic, so it definitely fits some developers better than others. For instance I find it easier to understand than CodeIgniter, but that's just because of my personal process: I prefer to read code than documentation, and CI's code is so full of crap, my mind shuts down. But for most developers CI is a lot easier to learn than ZF, and not everyone agrees that CI's code is full of crap. The important thing is that a framework isn't supposed to be hard to use, if it is there are always others out there.
    – yannis
    Commented Dec 6, 2011 at 7:28
  • I find Zend Framework 1 to be relatively easy to grasp. But you said the idea behind ZF2 was to make it easier, I feel like it's much more complex than ever before.
    – bought777
    Commented Sep 27, 2012 at 7:00
  • Everything in ZF2 is overly complicated. It would be OK to present Zend "framework" as a collection of modules/libraries. The actual framework is missing. There is no model layer, so you either have to implement your own, which is usually a mess or use Doctrine, which requires some integration. To write some unit tests you need to spend a ridiculous amount of time deciphering the manual and writing (or trying to find online) some code just to bootstrap your tests. While it may be built around sound concepts, their interpretation of those concepts is terrible.
    – vladko
    Commented Apr 28, 2016 at 12:38
11

I didn't like the lack of discoverability when I started using the Zend Framework, too many classes rely on arrays and you have to lookup what keys you can/need to define.

There is nothing at all wrong with having clear set methods or named params, it would, imo go a long way to helping with discoverability.

The Yii framework is even worse with this sort of thing.

3
  • 3
    +1 My significant reason for not seriously considering the uptake of ZF / ZF2 has to be the ugly, auto complete / hinting and inteli-sense dodging nested array based configurations. It infringes my personal dislike of the overuse of arrays in an OO world. Commented Nov 11, 2012 at 23:47
  • 1
    Precisely my opinion as well.
    – Daniel
    Commented Mar 6, 2013 at 12:04
  • I don't find Yii 1 as too difficult. Maybe that's for me. :P Commented Jan 15, 2016 at 6:03
5

Some problems with ZF, which make it annoying (and hard for beginners) to work with:

ORM not included. One would think that this should be very base of modern MVC framework, yet ZF only comes with Zend_Db_Table, which is ridiculously low-level. You can use Doctrine, but then you're on your own, it's not in any way integrated with ZF.

Unreadable, bloated URL routers. For example it takes 9 lines of code to define the very simplest of routing:

$route = new Zend_Controller_Router_Route(
    'archive/:year',
    array(
        'controller' => 'archive',
        'action'     => 'show'
    ),
    array('year' => '\d+')
);
$router->addRoute('archive', $route);

Given amount of question related to this it's anything but simple for most people. Also, I can't help it and compare it to Django, where the equivalent of above it would be

url(r'^archive/(?P<year>\d+)/$', 'archive.show')

Zend_Acl is way to complicated for most of use cases. Normally you'd have authentication to identify user. And an option to easily limit access to some controllers only to authenticated users. For many user case that's enough. For more complicated case it would be up to business logic in controller to determine if user has permissions to perform certain action. In ZF you don't have option to easily limit access only to authenticated users, the standard way is to use ACL and roles system, regardless how simple your need actually are.

Bloated directory and file layout. Recommended directory structure looks like this:

<project name>/
    application/
        configs/
            application.ini
        controllers/
            helpers/
        forms/
        layouts/
            filters/
            helpers/
            scripts/
        models/
        modules/
        services/
        views/
            filters/
            helpers/
            scripts/
        Bootstrap.php
    data/
        cache/
        indexes/
        locales/
        logs/
        sessions/
        uploads/
    docs/
    library/
    public/
        css/
        images/
        js/
        .htaccess
        index.php
    scripts/
        jobs/
        build/
    temp/
    tests/
4

Zend Framework is like a bunch of independent libraries which together works like a framework. It is very hard to develop something at the same time decoupled and "easy to use". For "easy to use" I mean doing complex things with few lines of code.

So, starting with Zend is harder then other frameworks, like CakePHP. But I it also easier extends and customize your application with no dirty codes. Zend also follows standards and design patterns all over its code, so once you read the framework code, you can guess what's going on.

When you say you have no clue about how models, views and controllers work together, please, don't blame the framework. It implements MVC like any other framework, except it separates the Model from the Database structure, which in a lot of frameworks are implemented in the same class. So you gonna face a lot of classes like Zend_Db_Table, Zend_Db_Table_Row, Zend_Db_Table_Rowset, etc...

That's why I think Zend Framework is more complicated, because it is very decoupled and you can use its classes in others projects which don't use ZF.

3

Zend Framework requires some solid grounding in OOP and Design Patterns. From my experience, I only find experienced Java-JEE-Struts-Spring Programmers that easily become familiar with Zend Framework. Average PHP Developer finds it hard to digest the concepts and Architecture behind Zend Framework. But see hey ! Zend Framework comes from company 'Zend' that creates PHP in first-place. So it needs some thought maybe if not respect !

2
  • 1
    Rasmus Lerdorf created php, zend is a high supporter of php. From what i recall.
    – Exploit
    Commented Oct 31, 2013 at 3:04
  • Cant disagree there. Im a Java Developer. I not only found my way into ZF easily but preferred it to other frameworks.
    – somejkuser
    Commented Oct 27, 2016 at 18:41
-2

I believe zend is just to make things complicated, MVC is just a fraud logically its working like plain PHP. but you are developing it in front of MVC, like separating files in different directories.

Remember that who is saying that Zend is very secure and and unable to hack, is a big fool. Zend can also able to hack easily if you didn't use Mysql injection protections. I whould like to suggest you define your own functions, then separate your files in different directories to make it similar like MVC save your functions, classes, and other core material in one directory called controller then add your web pages in different directory where you need to include all those function files this directory will know as view. place your javascript and css files in different directories which will known as model.

Remember that, in this world many of people always work hard to make thing more complicated, because they are themself complicated to understand.

PHP is the language which you have learn in book and from teachers. Zend is nothing just a framework, to make things complicated for your clients. so whenever there client need any modification they will run back to the real developers and those developers will charge you more money. Zend is protected its all just lie, a single mistake like plain php coding can cause the website hackable.

-6

At least the "quick start" thingy must be easier in order to make a framework friendly.....if you prefer something harder as a better thing then I would say "ZF is the best PHP framework", otherwise NOT. I've downloaded ZF-2 and tried it out (honestly I am newbie to ZF). Sad thing is that I still haven't found a solid "quick start guide" with a simple Project Skeleton on the internet. All I am looking for is simple way of including library files and creating a project folder with MVC features. I have used Codeigniter, Cake php, Yii but i found it pretty unfriendly. Yes i know Zend upgrades PHP but it doesn't mean that it's the best framework or whatever you'll say.

1
  • keep on disliking....LOL
    – Ram
    Commented Oct 12, 2012 at 8:44

Not the answer you're looking for? Browse other questions tagged or ask your own question.