tags:

views:

2383

answers:

7
+10  Q: 

Zend PHP framework

What are the advantages and disadvantages of this framework when compared to other PHP frameworks?

+1  A: 

You may want to check out these topics if you have not done so already:

What PHP Framework Would You Choose for a New Application and Why?
Which PHP Framework will get me to a usable UI the fastest?

andyuk
A: 

The only other framework I know of for php is cakePHP. cakePHP is a MVC framework that is suppose to imitate the beauty of rails.

Zend looks like it covers a broad range of things, but not MVC. I think it will come down to personal preference. I recommend building a sample application in each the Zend and cake frameworks to see which you like best.

Ethan Gunderson
Zend clearly does support MVC, albeit differently. There is also CodeIgniter, which is perhaps less widely-used than CakePHP but which has similar goals and is designed for MVC development.
Don Jones
+7  A: 

We make moderate use of the Zend framework and heavy use of CakePHP. My perceptions so far are:

  • It is exceptionally well written and designed. You can get a lot out of it just seeing how they did it
  • It plays very nicely with other code, you can use as much or as little as you want of it to good effect
  • Some of the things it gives you are invaluable - Lucene bindings, Google services etc.
  • Its MVC stuff is less well developed than other frameworks
  • To use as a full MVC framework there is a higher barrier to entry, and it gives you less for free, but the flip side is it can be made to work how you want

In short it favours configuration over convention (opposite of Rail-a-likes). I can't imagine not having it in my toolbag, but every time we've gone to start a project wholly with it, it's just asked too much of us and we've reverted to CakePHP with Zend right there in our initial repository templates as an external.

reefnet_alex
A: 

I'll echo reefnet_alex in saying that the Zend Framework is an excellent library, but if you are looking for MVC then it is no small task to configure a working site. That being said, once configured the MVC stuff is excellent and infinitely flexible unlike most frameworks which force you into using their conventions.

If you are not looking for MVC then there is no better option for a full featured and mature framework.

Prestaul
+17  A: 

The Zend Framework is very helpful framework. I'm hesitant to call it a 'framework' because it's designed more like a library. It's ability to lets you pick and choose the components which makes it a very convenient for whatever project you are working on, new or old.

I also appreciate the the dedication of the Framework to PHP 5. I have used other frameworks like CakePHP and I was disappointed in their use of the new features of PHP 5. In particular, ZF uses many of the object oriented concepts like Abstraction, Inheritance and implements a number of methods form the Standard PHP Library. For example, the results of a call to database through a Zend_Db_Table adapter returns a "rowset" object instead of a basic array. The "rowset" provides its own useful methods, but also implements both SeekableIterator and Countable. This allows you use the "rowset" object directly in common PHP functions like count (Countable) and forach loops (SeekableIterator). Here is a modified example from their documentation:

$rowset   = $bugs->fetchAll("bug_status = 'FIXED'");

$rowCount = count($rowset);

if ($rowCount > 0) {
    foreach ($rowset as $row) {
        echo $row->bug_status . '<br>';
    }
} else {
    echo 'no rows matched the query';
}

ZF also allows a great deal of customization by allowing your to extend their basic class like the Zend Db Table Rowset. With this you can add functionality to the rowset and get Zend to utilize your classes by default. This allows me get to much more solid object oriented code, rather just boxing data up behind a "class".

A small point, but worth mentioning, is that the Zend Framework has taken into account existing design patterns when building their solution. The Zend Db Tables classes takes inspiration from Table Data Gateway and Row Data Gateway. For me this is helpful because it means I can reference existing solutions and learn from them.

My response centered on the database aspect of ZF, but I think a lot of power can also be found in all of the other service (Lucence, Amazon, Flickr, Yahoo, etc) and common function classes (PDF, Currency, SOAP, JSON, etc).

Finally, a number of people have mentioned concern about the difficulty of setting up ZF projects. I tend to agree that there can be some bumps when starting a ZF project, even though they tend to run well once configured. However, the latest release, 1.6, contains a new tool aptly named Zend_Tool for setting up all of the essential elements for a full ZF project. Here is the Zend Tool setup tutorial to give it a try.

Barrett Conrad
The extensibility feature is a key difference between a library and a framework.
Bill Karwin
+2  A: 

I'm new to the MVC approach, but, an old hand at PHP. I have to say, whilst I've not compared it to the other frameworks, I'm most happy with the consistency and simplicity the framework brings to my applications.

Yes, it can be a bind to get it setup right, but, I've now created a skeleton project, and some build scripts that I use with my databases. It's a simple case of creating my database, checking out from source control, setting my config file then running my build script to create models. I'm then able to create new project, check back in to source control and start from there.

Once I've got that base project in place the MVC approach is extremely clean for creating large applications.

Add on top of this the other components of the library, Zend_Mail, Zend_Date, Zend_Form (which has saved me so much boring stuff), Zend_Registry, Zend_PDF, the list really does go on and on.

All frameworks are going to take time to learn, but for my time and money, ZF is the best option going forward. It's also extremely good for PHP in general, trying to bring some consistency and quality to code is good for developers.

The inclusion of DOJO and the JSON view modes means I can quickly put out some really good client side applications that are easy to debug (using the new FirePHP / WildFire component) using Firebug.

I just really appreciate the approach.

Andrew Taylor
+8  A: 

I managed the Zend Framework project through its 1.0 release, and I wrote a lot of code in Zend_Db and other components.

Other people have been commenting on Zend's technical advantages, its use-at-will design, etc. There are a few advantages that get overlooked:

  • The Zend Framework project has a very strong goal for quality. There are over 8,500 unit test functions, and the test code accounts for about 42% of the total PHP code in the project (measured by lines of code).
  • The code is clean IP. From the very start, Zend Framework's goal was to provide code that was free of any patent or copyright claims.
  • The New BSD License is the basis for the Zend Framework license, making it friendly to commercial use (more so than GPL).
Bill Karwin