Posts Tagged ‘pear’

Book review: PHP Objects, Patterns and Practice (second edition)

Tuesday, June 3rd, 2008

Apress sent me a copy of “PHP Objects, Patterns and Practice (second edition)” by Matt Zandstra to review.

As hinted in the title, this near 500 page tome is split into three parts: objects, patterns and [best] practice.
The section on objects covers the basics and then the advanced features of object oriented facilities in PHP and tools such as namespaces, autoloading and the reflection classes along with design basics, class scope, encapsulation, polymorphism and some UML.
The patterns section is obviously inspired by “The Gang of Four” (Erich Gamma, Richard Helm, Ralph Johnson, and John Vlissides) and covers what design patterns are, enterprise patterns, database patterns and also the basic patterns such as the factory, fascade, decorator and composite patterns along with a few more. This section is far from comprehensive, but is a good start. (If Patterns do interest you, and they should, have a look at patternsforphp.com)
The last section, focuses on PEAR (including writing your own packages and setting up your own PEAR channel), phpDocumentor, unit testing with phpUnit, version control with CVS (which struck me as a bit odd – I had expected subversion to be covered either instead of or along with CVS) and setting up automated builds with phing.

While being an easy read, this is a well written, serious book and is aimed squarely at enterprise-level developers and software engineers who make their living through the development and architecture of solutions developed in PHP.
Any PHP developer wishing to improve his skills should get a copy.

The Date_Holidays package, a pack of splitters and a pear tree.

Friday, May 9th, 2008

Some of you may know that I am a lead developer of the pear Date_Holidays package.

Date_Holidays helps you calculate the dates and titles of holidays and other special celebrations. This is all driver-based so it is easy to add new drivers that calculate a country’s holidays.
Until recently all of these drivers for individual countries were grouped together into one package.

We decided that this one package should be split into subpackages: one subpackage per region/country. Some advantages of this approach are that each driver / filter / subpackage gets it’s own stability and version number – we wouldn’t have to keep increasing the version number of Date_Holidays each time a new driver is added or when an existing driver gets a significant number of fixes.

Therefore we now have subpackages such as Date_Holidays_Austria, Date_Holidays_Brazil etc etc.

If you want to use the new set of [sub]packages, the simplest thing to do is uninstall the package that you have installed:

$ sudo pear uninstall Date_Holidays

and then install the new package, with a group directive which will install all subpackages:

$ sudo pear install Date_Holidays#all

Book Review: The PEAR Installer Manifesto

Tuesday, March 11th, 2008

Book Review: The PEAR Installer Manifesto by Gregory BeaverPackt Publishing.

When I was asked by a Packt representative if I would review the book “SOA Approach to Integration” by Poornachandra Sarang, Frank Jennings, Matjaz Juric and Ramesh Loganathan I was told I could pick a book of my choice as a “thank-you” for writing that review.

I jumped at the chance to obtain a copy of “The PEAR Installer Manifesto” – and have now been asked to write a review of it, so here goes:

The book is approximately 270 pages long, split into six chapters, and is aimed at PHP developers who “want to understand how the PEAR Installer works and what it can do for them” and also for those “seeking a better way to deploy their applications and manage updates”.

The six chapters are:

  1. What is it and how do I get it?
  2. Managing PHP Software Management with the PEAR Installer
  3. Leveraging Full Application Support with the PEAR installer
  4. Clever Website Coordination using the pear Installer
  5. Releasing to the world: PEAR Channels
  6. Embedding the PEAR Installer: Designing a Custom Plugin System

Chapter one explains what PEAR is, how to install the PEAR installer and how to deploy PEAR packages remotely onto a server over FTP – proving that no matter what way you access your production servers you can, and should, be using the PEAR installer.

Chapter two covers versioning, package.xml and roles; teaching how to turn software written in PHP into discrete distributable packages.

Chapter three focuses more on version two of package.xml (chapter two briefly covered both versions 1 and 2 of the package definition file) and explains how to bundle a package with its dependancies.

Chapter four is about source code control and performing roll-backs on pear packages – essential tasks when it comes to managing a complex website.

Chapter five details how to set up a channel server, outlines various ways to distribute packages and applications using channel servers and discusses related security issues.

Chapter six closes the book with an explanation of why you might want to embed the PEAR installed, a discussion of several methods of handling plug-in systems and designing a custom PEAR channel-based plugin system.

As a PEAR developer who’s going through the process of getting a new package proposed and accepted I found the discussion of package.xml enlightening – much more so than the current online documentation.

As a developer who has occasionally needed to rollback changes pushed to a production server… well, if chapters two and three weren’t eye-opening enough; chapter four definitely was as it details how to employ the PEAR installer to update and rollback live code so you can quickly revert back to a known working version of the site.

Though they are relatively few the book is not without its flaws: there is a small number of spelling mistakes present and considering the book was published in 2006 I don’t think it unrealistic to expect these to be corrected in an on-line errata. Other than that I found “The PEAR Installer Manifesto” to be a nicely focused, well written book grounded with good case studies and real world examples.

Authored by the authority on the PEAR installer the book couldn’t get much better. Highly recommended.