PHP In Action

PHP In Action

“Objects, Design, Agility” — the subtitle sums the book up quite well; PHP In Action is all about object oriented programming in PHP. I owe its authors a lot for having introduced me to the wonderful world of OOP.

PHP In Action starts off with an introduction to classes, objects and inheritance. For the beginner programmer this is vital reading but if you can already tell an interface from an abstract class, you might as well skip ahead to part two.

The second chapter is what I felt was the gem of this book — test-driven development. It goes through the why, what and how to test your code. Even complex cases are discussed and we are shown examples of how to mock integrations with other network services.

Moving on to the next part, we are introduced to templates and representation, with libraries like Smarty and PHPTAL. Sadly there is no mention of Twig, which shows the age of the book. To offset that though, PHP In Action goes through a secret technology crush of mine; XSLT.

Lastly comes the chapter on database management. You learn how to safely construct dynamic queries, how to avoid SQL injection and how to optimize your database queries. We are introduced to the Table Data Gateway and Active Record patterns, which both are good to know. I do miss an introduction to the Unit of Work pattern however.

Written by Dagfinn Reiersol, Marcus Baker and Chris Shiflett.


I really liked the pragmatic approach of this book, where they teach by sample code instead of generic, abstract discussion. This is a great approach for the self-taught programmer to learn on top of her previous experience.

As with all tech writing, time is not an ally and this is evident in some sections of the book. PHP 5.2 was the current version at the time they wrote it, which means there were no closures, no namespaces and none of the modern >5.3 frameworks existed.

Despite this, PHP In Action remains a solid foundation for anyone seeking to dive into test-driven, object oriented PHP programming.

Get PHP In Action now!