By Harry Fuecks

Zend Framework: Looking Good

By Harry Fuecks

Like quite a few people I guess, been absorbed by looking at the first release of the new framework.

Originally had been keeping notes on impressions but feel there’s not much point at this time – the first release is “preview” quality and rough edges are a given. Right now it’s only suited to experienced PHP developers wanted to get an idea of what’s coming – wait and avoid frustration.

It could be argued that it’s been released too soon – it fails Marcus’s install me test, at least as far as the controllers are concerned, which is what I guess most people want to see. Unlike Ruby, PHP is a language that many people know well and are more able to form valid opinions about, so the audience is likely to be far more critical and releasing early risks negative review.

That said, I’m personally happy Zend have got something out of the door. Having having sniffed around for a while, I’m also cautiously optimistic.

Building Consensus

The most positive impression I get out of the preview release is that Zend is laying down various conventions for how to “do” libraries and re-usable code in PHP.

You can get an indication by reading Rob Allen’s blogs on the front controller and views (Rob made it to the PHP London Conf BTW) – notice how he’s organising his own namespace on the filesystem and implementing some of the Zend interfaces;


If you have the above lib directory in your include path, you can load the classes via the Zend::loadClass() method.

This is just suggestive but because Zend has the weight to get the ball moving, can see them being to generate agreement and conventions on how libraries and framework extensions are deployed. If the Zend framework starts show up in linux distributions and is installed by default by hosting companies, there’s a strong incentive to do things the same way.

That in itself would be a huge plus for PHP, encouraging organisation and providing focus to people writing Open Source PHP libraries. Today putting a project together using third party code means either much glue or hacking the source – with the Zend framewark as the central point, we finally start to get some organisation out of the chaos. Add to that that the framework itself is eliminating the need to re-invent certain wheels, like what’s provided by the InputFilter, as well is providing extension points like the custom view helpers or some of the interfaces they’ve included (DI is needed though – more below).

Choice is still an option

If you prepared to accept the Zend framework at the center (and I don’t think there’s really anything harmful in that, other than perhaps an opcode cache being a good idea), there’s plenty of room to distribute your stuff as add-ons to it.

For example, the framework doesn’t implement a template engine as such, your view scripts being straight PHP (I guess this is based on Paul’s experiences with Savant). There’s nothing to prevent Smarty or WACT from distributing their template engines in a form which is “ready to roll” with the Zend Framework, and in fact there are good reasons for doing so – if the Zend Framework gets wide acceptance, being “Zend Framework Compliant” (logo anyone?) will add legitimacy.

Similar goes for eZ components – these could readily be made to fit into the Zend framework, providing a bunch of stuff that the framework doesn’t do and choice on some of the things it does.

Also, looking at the controllers, I get the impression the default design is going to work in a somewhat Rails-like manner – user defined controller classes with class methods corresponding to particular actions / urls. Personally I’m not particularly enamoured with that approach and would rather see something similar to;

class WikiPage extends Resource {
    public function GET() {
        // response to HTTP GET
    public function POST() {
        // response to HTTP POST

What so far seems to be the case is that I’ll be able to have my cake and eat it – should be possible to construct this kind of API within the current controller design, with a little extending and implementing of existing APIs.

Killer Feature

Right now think the strongest feature it offers is the search facilities (not yet complete / stable though), which is port of the Apache Lucene (Java) project to PHP. Right now there basically isn’t a decent search toolkit, native to PHP (other than building extensions to projects like Xapian). Can already think of a one project that had to roll it’s own.

Again the way the API is designed, it would be possible for projects using the Zend Framework at their core to tap into the search indexing features, thereby allowing users to have a “unified” search across the various applications they use on their site.

Otherwise, although not exactly a feature, it’s really nice to look at code which has clearly be written in a consistent manner and is well documented.


Now there’s a bunch of minor issues I could raise (e.g. the Feed API is very cool but what about character encodings?) but won’t at this time, given the preview status.

There are two big things I think are missing though.

First is the unit tests, which weren’t part of the download. I have the sneaking suspicion that may be because there aren’t any unit tests yet (slap me if I’m wrong), considering one or two of the release hiccups that happened. I know there’s pressure to get this framework “out there” but don’t sacrifice the unit tests (unit tests needs to be on this list)! There’s a bug tracker due online soon. An additional (and I’d argue more valuable) source of feedback would be the test results – if users run the tests and deliver them, say, by email along with a little information about their environment (PHP version, OS etc.), you have a very good indication of how solid the framework is – a giant build farm if you will. Otherwise unit tests are essential to building trust with users (developers).

The other one, which is more obscure, is dependency injection, which I’m sold on after Pawel’s talk. Believe Sebastian of the contributors has some experience there. What Pawel convinced me of with the PHP version of picocontainer is that it can be done in a “lightweight” manner for PHP, that won’t eat resources. For the Zend Framework this seems critical if it’s to become the central “integration” point for other projects – rather than specifically loading and instantiating objects, dependency injection would allow components to obtain “services” via the framework, leaving it up to users to decide which implementation they want used.

Bottom Line

The Zend Framework is what PHP’s been badly lacking for a long time. It’s not ready for use productive yet, but it’s current form should give library developers an understanding of how their code can be made to fit with it. From where I stand, it is most definately not a threat and it constitutes the best chance we’re ever going to get to tie many thousands of hours work together into a coherent platform. Take it or leave it.

  • lsmith

    Well I think the ZF has potential, but I guess its biggest advantage is the hype its getting. This gives it the potential to define standards just like PEAR has done to some extent.

    Interestingly the ezComponents are in a much better shape already. Better documentation, tests (although these do not seem to be bundled with the PEAR packages) and general code maturity. However they have failed to generate the same kind of buzz. I guess it pays to be seen as THE PHP COMPANY.

  • Interestingly the ezComponents are in a much better shape already. Better documentation, tests (although these do not seem to be bundled with the PEAR packages) and general code maturity

    As said, don’t think the Zend framework is necessarily competition for those projects. Sure for specific libraries (e.g. mail, http clients, feed readers) it’s “competing” but that’s not really a problem.

    However they have failed to generate the same kind of buzz. I guess it pays to be seen as THE PHP COMPANY.

    Thing is ezComponents isn’t getting into MVC or telling you how to organise your code. ezComponents is more like PEAR – a bunch of libraries to use. The Zend Framework is suggesting how you organise your code, around their controller architecture and class loading strategy.

  • ordnas

    The UnitTests of eZ components will be bundled with the forthcoming release 1.1.:

  • Ren

    Not sure how usable the FC/Routing is atm, seems lacking url generation, which when playing with Url paths becomes almost essential, as can no longer use relative urls to things like images, and css.

    If the Zend object became a DI container, that’d be really nice, and perhaps eliminate crufty looking things like



    Also presuming that ZF will be getting a pear channel, perhaps be nice if pear could run the unit tests after downloading, and have the option to roll back if the results change from the previous install version. Can pear do that?

  • ordnas

    @Harry: concerning what you say about “suggesting how you organise your code”, there are of course pros and cons when it comes to the flexibility that a framework provides to you.

    I would not go as far as Joel and write a blog entry “Why I hate frameworks”, but he of course got some points worth considering:

  • WebDevGuy

    To start my understanding, is this like Eclipse is to Java – a framework in which others may build components that “clip in”?

  • there are of course pros and cons when it comes to the flexibility that a framework provides to you.

    That’s very true. At the same time “smart defaults” are “in” plus someone has to set up some basic conventions and services otherwise we can carry on as always with wheel re-invention, glue, hack and paste.

    To start my understanding, is this like Eclipse is to Java—a framework in which others may build components that “clip in”?

    I guess so – if we say Eclipse is an IDE plus it defines a plugin framework to extend the IDE then this is a web framework plus it defines conventions / plugin points to extend the web framework. It may not quite be “Clip-in” yet but it could get there.

  • Jason

    Over-rated. Not needed. Makes coding more complicated than it needs to be.

    This is PHP, the black sheep in the world of white sheep.

  • Over-rated. Not needed. Makes coding more complicated than it needs to be.

    This is PHP, the black sheep in the world of white sheep.

    That’s a valid point of view although I’m not sure I agree about the “more complicated” part – if you look at the Feed stuff for example, there’s some very slick use of the SPL extension which makes reading and creating feeds very easy. Likewise looking at this example – that doesn’t look hard to me. MVC? Well there’s perhaps another story but…

    Of course there’s nothing requiring you to use the Zend Framework but when you run up against someone churning out working code faster, using the framework, you may want to consider joining the assembler programmers over at the dhs – they’d no doubt also agree it’s not needed.

  • Matt

    I just read through the manual on Zend Framework and for the most part, I really like the implementation. It is a collection of a number of classes I already use from around the net.

    My major problem is their stupid coding standards; I honestly hardly agree with a single one of them… it actually makes me mad. Here are a few that I read through until I got so mad I just closed the damn manual site and did something else (wrote this angry post).

    [quote]B.2.2. Indentation
    Use an indent of 4 spaces, with no tabs.
    B.2.3. Maximum Line Length[/quote]
    I despise spaces in code… why hit the space bar 4 times when you could hit tab 1 time? So what, you have different editors with different default tab stops… who cares, it’s a preference. I refuse to use spaces.

    [quote]B.2.3. Maximum Line Length
    The target line length is 80 characters, i.e. developers should aim keep code as close to the 80-column boundary as is practical. However, longer lines are acceptable. The maximum length of any line of PHP code is 120 characters.[/quote]
    No way, not in a million years. I like long lines… sure, I may have to scroll horizontally to see some code, but a single like if statement is a hell of a lot simpler to read if you’re looking at the whole file or a large chunk of code.

    [quote]B.3.3. Filenames
    Files that are containers for single classes are derived from the class names (see above) in the format “ZClassName.php”.[/quote]
    Whatever… this is stupid as hell. Have they ever used an FTP client before? Some clients by default change filenames to lowercase… like they should be. As far as I’m concerned filenames on the net should be a-z 0-9 – _ . period.

    [quote]B.3.5. Variables
    Variable names may only contain alphanumeric characters. Underscores are not permitted. Numbers are permitted in variable names but are discouraged.[/quote]
    Whatever… again, I $variable_name and refuse to use $variableName… If you have the words “some string” does it make more sense to say someString or does it look more accurate to say some_string. My opinion is the later. camelCaps is ugly in PHP code. I agree with their definition of Constants, but it leads to the question of… if underscores are permitted in constants, why not in variable names? If the answer is to clearly separate the two, then why shouldn’t variable names be all lowercase and constants be all upper case.

    [quote]B.4.2.4. String Concatenation
    Strings may be concatenated using the “.” operator. A space must always be added before and after the “.” operator to improve readability.[/quote]
    $whatever = “that is “.$tupid;

    I just give up… I refuse to conform to that less-efficient “standard”. My own personal “standard” is almost the exact opposite of this Zend outline and in my opinion it is much nicer to read through and work from. I’m actually a Graphic Designer turned developer… my whole education and philosophy revolve around making things look good and stay functional… I personally think I’m qualified enough to say those standards stink. :P


  • I don’t think ZF will really be the mother of all frameworks. People will soon find it both incomplete (for real life uses) and limiting (what’s with the __autoload()?), and start creating their own versions of it.

    Shared libraries are a much better way to go, although we need to define a standard way of organizing and naming classes.

  • siteartwork

    I guess you’ll be pretty much alone with that. The standards used in ZF are almost identical to PEAR, you can also almost match them 1:1 to other os-projects from other languages.

    Hell, I even have noone seen complainin about the coding standards yet! Browse to the sources and see if you can find some really important issues…

  • Matt

    Thanks for the response. Unfortunately, that is my main problem with Pear as well, the ugly standards. You’re right though, I should definitely have had a bit more amunition before posting that… I’ll see if I can find some specific codeblocks I see as “problems” and post that.


  • jimbo

    I have been using symfony ( for a while now and I really like it. I am interested to hear any one’s views on how the Zend framework compares to symfony.

  • McGruff

    In business, you have a decent chance of success with good marketing and a bad product but little chance of success with a fantastic product which is badly marketed. It almost doesn’t matter what the code is like: good or bad, the Zend framework will grow to be the default simply because it’s the Zend framework.

    A preview release doesn’t have to be perfect. Bugs don’t trouble me at all but design choices might. What I’m looking out for now is how well the Zend team respond to suggestions from the wider community. Frameworks are hard to get right and I hope they’ll take as much time as necessary to create some good OOP code. That will be easier to do at the start but much harder later.

    I’m slightly concerned by a comment on the mailing list: “A ‘better’ but more complicated and less accessible design would not help us achieve our goals.” I’d prefer a no-compromise approach committed to making decisions purely on design terms.

  • McGruff

    Matt: if you put a dozen programmers in a room you’d get at least 13 different proposals for coding standards… Mine are the only correct ones, naturally :)

  • McGruff

    PS: I’m really looking forward to a surge in interest in testing as one of the spin offs from the Zend framework. Shame they’re not using SimpleTest though ;)

  • Anonymous

    If coding standards are going to crimp your style so much that you’d rather reinvent the wheel and write your OWN framework, then go. Don’t waste my time griping.

  • mx2k

    i’ve been waiting around for the framework forever and a day to come around.

    Its very curious. I noticed the data adapter forces you to use naming conventions and looks like it makes use of magic methods __get() & __set() internally. (they might be using other means).

    the data adapter takes the name of your class, makes it plural and then looks up your table in the database.

    so if you name your class ‘Car’, it looks for table ‘Cars’. then it generates the properties for you based off the fields in the table.

    I can see this could save you time, but you would sacrifice some flexibility in coding by using this class. (i’m sure some people know that i’m sucker for being about to use properties in this manner though)

    $person->firstName = "test";

    rather than


    (and maybe one day php will get property accessors so i could do the following)

    class Person {
    private isDirty=false;
    private firstName;

    public FirstName {
    get { return firstName; }
    set {
    if(firstName != value){
    firstName = value;

    private function MarkDirty(){ isDirty=true;}

    public function Save() {
    // save logic here

    but i am digging on Zend_HttpClient_Response and Zend_HttpClient

  • heathd

    Depenedency Injection. It’s such a powerful yet simple idea, and it’s the only design I’ve seen which would allow clean integration of libraries from different sources. For a framework it’s a must have!

    I also agree about the Unit Tests. These should be published and easily runnable.


  • Jeewhizz

    I have the sneaking suspicion that may be because there aren’t any unit tests yet (slap me if I’m wrong), considering one or two of the release hiccups that happened.

    Unit tests are due for release asap from what I’m reading on the mailing list.

  • Pingback: Jelly & Custard » Zend Framework()

  • Pingback: Rhyll > PHP Blog > Zend Framework Preview Release()

  • Pingback: Rami Kayyali’s Scatterism Archive: Random Highlights()

  • Pingback: Zend Framework - namiastka Ruby on Rails?()

  • sohail

    hi everyone,

    I am new to programming world, started using phpmailer but this doesn’t support ssl with php, so someone advised me to use zendframe work. I downloaded the latest ZF zip file, it has got loads of libraries including to create pdf documents. But i am not sure how to install zendframe work on my server and use some of its librarie ie., pdf generation and zendmail.

    Sorry for being so dump, everyone on this forum got a better understanding of zendframe work, but for me its just bit over the head.

  • Anonymous


Get the latest in Front-end, once a week, for free.