PHPDEVELOPER.ORG ADOPTS THE ZEND FRAMEWORK
Chris Cornutt, the developer behind phpdeveloper.org recently launched a major overhaul of his site. In addition to the sleek new look and feel, the underlying code was also rebuilt on top of the Zend Framework. The site, now 6 years old, is now in it’s 3rd major re-write. In his initial announcement of the re-write posted on the site, Chris had this to say about the Zend Framework.
“When Zend posted their first preview release of the Zend Framework, we had to admit that we were hooked. As has been mentioned several times by many people all over the PHP (and programming) community, working on a project is the best way to learn a new method/software. Our project was the redevelopment of this site.”
I caught up with Chris by phone recently to talk about the site, the Zend Framework and what it took to re-build an existing site, against the common wisdom of “Don’t re-write your core application”. Chris explained to me that the 2 previous versions had been built around internal classes and were built on the traditional “1 page, 1 function” model of scripting. When he decided that it was time to re-write the core code base he decided this version would be built on a framework. He chose the Zend Framework, preview release 0.1.3 to build the next generation of his PHP news site.
Why did you choose the Zend Framework?
Honestly, I wanted to see what was behind all the hype. Ultimately I knew that it was going to be a force in the community and I wanted to catch a few people’s eyes.
What other frameworks did you consider before settling on ZF?
I looked at SOLAR but I never had a chance to get into it. Then Zend released version 0.1.3 released and I figured I’d give it a shot and see how it goes.
What was the greatest challenge in working with the Zend Framework?
I think the greatest challenge had little to do with the framework. My biggest challenge was that this was my first MVC application. Before this, all my sites had been built on the traditional “each page contains all the code necessary to do it’s work” model. I wanted this one to be built on MVC. It took some time to understand how to build in the MVC model, but once I got my head around that it all started to fall into place.
How do you like MVC vs. traditional procedural scripting?
You know, I kind of like it better. The biggest advantage I see is that my code is a lot cleaner. This is version 3 of the code that runs phpbuider.org. Each version got a little better and a little cleaner but overall, it still felt bloated. This version, built on the MVC model and on the Zend Framework. With the bulk of the code contained in the framework, the code base overall is a lot cleaner and it’s easier to add on new features. If I have a new idea, I just add a new action and I’m pretty much done.
Having worked with most of the framework pieces now, which piece worked best?
The Zend_DB module worked the best. Having written my own abstraction layers in the past, I know how difficult it is to make that work. For me, Zend_DB was the easiest part to make work. I also used the PDO layer and it was great because I could just tell it what I need to it gives me what I want.
I also really like the Zend_Filter module. It was really great not having to explicitly deal with user input.
What other components did you use in addition to ZF?
None. I tried to stay as “clean” as I could. I did write my own class for akismet but other than that it’s just standard framework.
Now that your site is live and you have had to make a couple of changes, how easy has it been to modify your newly written code?
The old way – the 1page, 1function method – had it’s advantages but overall, I find it easier to find and fix the bugs in this new MVC version. Since the bulk of the code is in the framework and already tested, you generally know that if there’s a bug, it’s something you wrote. So you don’t have to go tracing through all of the code and classes, you can concentrate on the code you wrote.
Have there been any downsides to building on ZF?
I think the only downside to using the Zend Framework right now is that it’s not 1.0, its still a work in progress. This means that things are still a little quirky or don’t work the way that you think they should. Other than that, no there were no real downsides.
To get things started, I followed Chris Shiflett’s tutorial on php|architect. That got me into the MVC mindset. Once I understood the main ideas behind MVC and the framework the rest was pretty easy.
What is your strategy for handing framework updates?
I actually have a development server that I work off of. When framework updates are released, I update the on the development server first. This way I can test them and make sure everything still works. If there are changes that need to be made, I can make and test again until I’m satisfied. Once everything works the way I want it to, I migrate it up to the production server.
What quirks did you find in the framework?
Probably the one piece of the framework that did not work the way I expected it to was Zend_Filter. It seemed to me that the filter should just take the input in and the spit the output back out on the other side; it doesn’t work that way. I probably spent 2 hours trying to get it to give me back an array that I could work from but the class just doesn’t work like that. You have to reference it once you give it the array. That just didn’t seem natural.
...I want to thank Chris for taking the time to talk to me and for providing us with the sight into what it took. I know everybody will be watching phpdeveloper.org as it grows and new features are added.
=C=

Comments
I'd read about the division of logic and layout, and even tried it some with the past site, but working with the MVC structure makes it even easier to understand.
It's amazing how simple an application really is when you get it back down to its base and code to that base, bulding up a foundation around it and a larger, stronger, sleeker new building on top.
The site looks great! I like the layout better than the old site and it does seem to load faster. I remember when I tried to get the PHP Group (Dallas) to have a meeting about the Zend Framework and nobody seemed too interested... maybe it was too early? Definately like what I see though.
I still think there should be Video Tutorials for the Framework. Ughhhh... people never listen to me lol jk
congrats on the site man, looks good!
- Clint
As a PHP developer, I know what it's like to go through dozens of recodes, and still feel like your code is lacking. I'm currently going through a recode myself. I am not going with the Zend Framework, nor the MVC pattern. I have chosen to code a framework that still separates data, from logic, from presentation, and still allows me to keep the "one page, on focus" mind of thinking. It's not that I don't like the MVC pattern, I'm using it on another project. It's very nice indeed. I just feel that I would like to work with "one page, one focus" method for this site. It may mean slightly more code for each page then with the MVC pattern, but I'm sure I'll manage. designing the framework is the hard part anyway. Once I(we actually) get past that, the rest should lighten up.
Anyway, I just wanted to say congratulations on finding something that works for you.