views:

611

answers:

7

I'm not a troll and my goal isn't to start a flame war; neither do I mean to disrespect the authors of the Zend Framework: there is a lot of fine work in it. But... I have a job to get done and I'm having a hard time reconciling the popularity of ZF against the reality of building apps with it. I would really like to know from others why they use Zend Framework.

I am fairly new to the PHP world but I've done a lot of programming in many languages. After reading many tutorials and building a couple of apps in it, some core Zend Framework facilities feel like alpha code to me. For me the following fundamental weaknesses, among others, would seem too overwhelming to consider deploying apps with it - but over and over again ZF is suggested as one of the, if not the leading framework.

First let me say I find the much of ZF to be workable. Routing works pretty much as it should, the Layout facility is serviceable (though very different from templating systems such as JSP/ASP), as is the cache facility, etc. There seems to be a tendency in the community to stuff a lot of modeling (e.g. validation) and view logic (e.g. $this->headScript() - why should my controller have to care which js file my view requires?) into controllers but could be a matter of usage and not necessarily the framework's fault.

Now for a couple of really serious (IMO) weaknesses I've experienced in my short time with it. I shudder to imagine the other areas I will discover in the future if I continue to build with it.

1. Form Layout
Many people seem to be unhappy with the lack of control over form layout. How can you have a popular framework where constructing a simple form requires so much discussion? Question 1 and question 2.

2. Authentication/Authorization
No one really seems to understand how to simply perform routine authentication/authorization. People [including yours truly] struggle with implementing simple access control. Further, the approach seems to lean on serialization for persistence, rather than traditional database storage of users and permissions. A confusing example, a proposal to enhance the facility, a tutorial - part I, and part II. This is too much work guys!

Are my perceived weaknesses not real or somehow not a problem? Why or why not? Why did you choose Zend Framework (or not)? Are there other areas that you've found to be so painful that you want to dump ZF for a different approach? Thanks for your opinions.

+3  A: 

One of the main benefits of ZF is that you can take any one of it's components and easily tie them in with your own (or a third party) framework with minimal modification.

cballou
+1. The first time I used Zend Framework, it was just Zend Lucene that I was after, so I used only that. That gave me the confidence that Zend is workable. However, I have to admit that I feel it is **monstrous** if used for every aspect of one's application.
namespaceform
+6  A: 

Because they are good at Marketing


Zend's founders Andi Gutmans and Zeev Suraski are key contributors to PHP

And they have one of the most complete framework for php.

When you think about it; it's like saying:

"Our language isn't as performant as it could be, so we made a framework with caching that makes it faster"

  • Most of what Zend offer, can be done without Zend.
  • But Zend's package is a very good "All in one" distribution.
  • They offer certifications and trainings.
mnml
-1 Not very constructive!
Lizard
well that's a short explanation to "Why is Zend Framework so popular?"
mnml
+1 I agree. There is a marketing factor involved, that is for sure
Elzo Valugi
Well the fact that the sell certifications and things like that is a very good marketing strategy, for most of their customers: Zend is to php what cisco is to networking.
mnml
"Most of what Zend offer, can be done without Zend." I didn't get the point :) It's like "Most things you can do with knife can be done without knife" (with something else like machette, sword, etc ;)).
Tomáš Fejfar
+1  A: 

Simplicity to build medium size applications. Until ZF you had to build your own "framework" to do medium size applications. Now is much more simpler.

I don't think decoupling and simple elements that can be used independently is the key to success. Is a nice feature, but is not the regular use.

Support and community size are relevant in the balance with other frameworks.

In terms of speed they are NOT better then other frameworks.

Elzo Valugi
+1  A: 

I did not choose Zend Framework because at the time when I was evaluating PHP frameworks it was not a complete and integrated enough solution for building web apps. I chose symfony and since then I have never had a need to switch to anything else.

I'm not sure if it's the same nowadays, but I always thought of ZF as a component library rather than a framework. A framework has a somewhat more strict rules of doing things and often has better integrated support tools to help people do them. A component library is more loose in this regard. When the framework rules correspond to the requirements of most applications in the framework's domain, I myself clearly prefer this solution. This has been the case with symfony for me. I do use certain ZF components as needed, but never base my projects on ZF itself.

Ree
I strongly agree with this, I come from a CakePHP/Rails background, and you just have to do a huge amount of work to get a form out there, which is not the fastest way to get a webapp running.
Shiv
+1  A: 

ZF is a good starting point. I used zend_tool to generate a MVC skeleton of my middle-size application and used many other components (Zend_Cache, e-mail, translate, forms, session).

And I agree that form layout is complicated if you are trying to do it as Zend says - with decorators. There are ways to use just Zend_Form elements with validation and in your custom layout - without decorators.

I had a bad experience with Zend Cookies - I just could not set a cookie for my entire domain. Old good setcookie did the trick right.

About Acl - again, examples in Zend documentation and Zend_Acl do not work well sometimes. I used Controller plugin approach and my own "role based resource management" to control permissions.

I did not even try Zend Data Gateway - used Doctrine instead (I guess that is because I like nHibernate :) ) And connecting Doctrine was really easy.

I think ZF is good because you can use it as you like. I think it would be harder with some other frameworks.

Martin
+1  A: 

Forms: The decorator approach is complicated, but bulletproof and priceless for applications with many forms. You don't care if you have 10 or 25 items in your form, the style is always the same. Saves you a great deal of work when you know how to use it. For users with simplier minds and goals there is always the viewScript decorator ;)

Auth/Acl: Never had any problems with these.

Zend_Auth::getInstance()->hasIdentity() //logged in

and

Zend_Auth::getInstance()->getIdentity()->role; //returns admin

For Acl:

$acl->isAllowed($who,  $where, $what);
$acl->isAllowed('roleAdmin', 'resourcePosts', 'create'); //returns true

Can be easily modified to match MVC:

$acl->isAllowed('roleAdmin', $module.ucfirst($controller), $action); //returns true
$acl->isAllowed('roleAdmin', 'adminPosts', 'create'); //returns true
Tomáš Fejfar
Perhaps my mind is too simple for ZF... Regarding Auth/Acl: Can you point to a single public example or tutorial that completely details [as downloadable and runnable code] how to use the current Zend Framework release (1.9, no "proposals" or "laboratories") to manage the authentication/authorization of three users/passwords in three different roles (e.g. guest, member, administrator) to protect three different controllers in the default module? This would be helpful to newcomers; if it exists somewhere I haven't found it.
Keith Morgan
Not aware of any. But I've get on just well with manual pages for Zend_Acl and Zend_Auth. Just the only question - where to handle the ACL - use front controller plugin and it's preDispatch method.
Tomáš Fejfar
A: 

Wel, we are developers because we are supposed to be able to write "some" of our own code, arn't we? Frameworks not supposed to be wizards, just an added assistance.

Billy Scholtz