Article
eZ publish: PHP's Killer App - Parts 1-3
Part 3
Welcome to the third installment of this series. If you've been keeping up with parts one and two, you'll have been introduced to the eZ publish content management system (which is in fact an application development framework in disguise) and installed your own version. By the end of part 2, you built your own fictional Website, phpPoint, and in doing so, learnt how to quickly apply your own design to the main eZ publish module: eZ article.
So if you've come this far, you'll hopefully be starting to agree that eZ publish is PHP's killer application. However, you may have been disappointed that despite all the many eZ publish modules available, there's still something you need, which isn't already on offer. That's what this article is all about.
I'll be taking you through building your own module for eZ publish. You'll get to see under the hood of eZ publish and find out how, by taking advantage of its structure and code library, writing and deploying your own applications is... eZ!
As an application development framework, eZ publish is designed to take the burden off busy Web developers like you and me, allowing us to spend more time soaking up rays by the pool (or at least dreaming about it).
But first, a word of warning. So far in this series no real PHP has been needed. That all changes here; we'll be taking the plunge head first into object orientation using PHP! Given the mission -- building our own eZ publish module -- I'm going to assume you have a basic knowledge of PHP's object orientation, so we can concentrate on the problem at hand. If you're unsure, make sure you've read Kevin Yank's Object Oriented PHP: Paging Result Sets, a great primer on how PHP classes work. That should give you all the skills you need for this article. If you want more, you'll find a comprehensive list of resources here at the SitePointForums.
Wait! Before you run off and hide, let me try to sell you the idea that object orientation is a good thing. As PHP coders, we're an impatient bunch -- we want it done now, usually with the first code that comes to mind. Perhaps we throw in a few user-defined functions when we really have to, but otherwise, it's code first, think second. That's all well and good, and PHP is a great language with which to build quick and dirty solutions, but how often have you found yourself entirely re-writing a piece of code you wrote months ago? And what about when you need to add new functionality to your Web application? Do you end up having to modify numerous scripts to make it all fit together?
With object orientation we can save ourselves massive amounts of time, producing code that is easy to read, update and re-use. If you make it your mission to put together a PHP class library with each project you work on, then the longer you develop, the bigger your library will get, saving you a lot of time on future projects.
But there's more to object orientation the just saving development time. Using PHP's classes, you can build far more powerful applications, accomplishing feats that would be either insane or nigh-on impossible with procedural code.
You first encounters with object orientation may leave you with the impression that it's just a nice way to put all your user defined functions in one place, for you to include in your otherwise procedural scripts. But the true power of object orientation is in how multiple classes interact. Imagine building a Website where index.php only contains...
include_once ('./phpbin/webengine.class.php');
$website= new WebEngine;
Once you get a toe in the door of object orientation, you'll probably never look back, but having said all that, building a fully object oriented application from scratch can often be a daunting task. That's where eZ publish comes in. As an application development framework, all the tough decisions have already been made for you. All you need to do is follow some simple guidelines and you'll be constructing your first object oriented PHP application in no time.
So by the time you finish reading this article you should have a good idea of how to write code which slots nicely into the eZ publish framework, while having gained a deeper insight into how to build object oriented PHP applications.
Here's today's shopping list:
- The Drawing Board: designing the application
- Class Act: putting together the classes
- Plugging In: fitting the code into eZ publish
- Zipping Up: the final act
Time to roll up those sleeves...