John Squibb
Appliances in PHP 5.3+
03 July, 2010
Software appliances are a great way to maintain portability via encapsulation. The concept of a software appliance is derived from the notion of a typical household appliance: a toaster or refrigerator does precisely what it needs to do, nothing more, nothing less. Simply plug it in and interface with it. The typical goal in creating a software appliance is to deploy software with little worry about OS dependencies, libraries, or other independent processes.
My goal, was simply to create some PHP objects, based on real-world household appliances, that rely on their own tightly knit set of interfaces, classes, and helpers. It probably goes without saying that PHP is very reliant on a decent amount of software to function. It is, after all, a scripting language, and depending on how you are interfacing with it, you're probably invoking a handful of servers, modules, engines, and whatnot. You may even be reaching across several operating systems to achieve this. In short, it is not my goal to create embedded virtual software. I am creating mock software appliances in PHP OOP.
Reasons
I like to write Object-Oriented code. It's a blast. Unfortunately, lately, I've had to code within an entirely procedural coding environment, day in, day out. To keep my OO chops strong, I was looking for some simple, yet fun projects to work on. One day, while doing laundry, I thought it would be neat to mock my washing machine in code. Voila, the first appliance was born!
Requirements
I'm using Ubuntu 10.04 on all my development boxes now, so it's PHP 5.3 and up for me, no looking back! It's as close to PHP6 as we're going to get for a while, but it adds a lot of great stuff. If you're not up to speed on 5.3, check out my article, Fun with PHP 5.3 to learn some tricks.
Base Classes
There are some base classes that many the appliances will make use of; Things like debugging, output, and benchmarking. Be sure to check out this section often, as it will continue to grow as new classes and methods are added.
Appliance List
The following is a list of appliances I have created so far. Keep in mind that they are ever evolving and subject to change.
Downloads
If you would like to download the entire appliance library, check out the following formats. In the root of the framework is a copy of the GPL. Feel free to modify, redistribute, and so forth. If you do anything cool with it, I'd love to hear about it!
Suggested Reading
PHP Design Patterns
by Aaron Saray
Seasoned programmers looking for a good book on PHP design patterns will thoroughly enjoy PHP Design Patterns.
Weighing in under 250 pages of readable content, it presents a truckload of philosophy and pattern samples in a well-condensed format, with short, consistent chapters.
The title starts off with a quick explanation of patterns, champions their usage, and by chapter 3, the user is thrust right into the Adapter Pattern.
For the next seventeen chapters, the user is given a synopsis, a problem/solution summary, a UML diagram, and code examples for each of the patterns in the discussed in the book.
Generally, the code provides a typical approach, and then a modified approach using the chapter's pattern.
Tags: Appliances, Namespaces, PHP, 5.3
Short URL: http://sqb.in/P2tv