Book Review: PHP 5 Objects, Patterns and Practice(Page 1 out of 2)
Welcome to the second review on PHPit. This time I take a look at "PHP 5 Objects, Patterns and Practice", written by Matt Zandstra and published by Apress. I've been trying to get into OOP and Design patterns myself lately, so this book comes at the right time. Read on to learn more about this book.
The publisher of "PHP 5 Objects, Patterns and Practice" sent me a free copy for reviewing purposes.
Title: PHP 5 Objects, Patterns and Practice
Author: Matt Zandstra
Length: 438 pages (18 chapters + two appendixes + index)
This book has definitely been an eye opener for me, and I've learnt plenty of new stuff. Usually I tend to quickly leaf through a PHP book, because most books tend to cover the basic stuff, but this one really covered new area for me.
It's often said that PHP 5 offers hardly anything new, but after reading this book you'll quickly reconsider. It explores every new feature of PHP 5, and it immediately shows you how to apply this new functionality in a practical way.
The book is divided into six parts, and 18 chapters. The first part is only one chapter, and is really more of an introduction to the book. The author explains the problem with PHP, and gives an overview of the things that will be covered in the book. Not really a noteworthy chapter, but it does explain the necessity for Design Patterns and OOP in PHP.
Part two, which consists of chapters two to six, runs through all the key concepts of OOP in PHP. The first chapter of this part, chapter two, is a really short one (three pages) and gives you a brief history of OOP in PHP. Chapter three will get you started with object basics. It covers most of the OOP basics, like declaring classes, using constructor methods, inheritance and a few more topics. Most of the stuff covered in this chapter was already familiar to me, and it will probably be to you as well. It's really basic OOP information, although a few new PHP 5 features are explained (such as visibility modifiers; public, private, protected, etc).
Chapter four introduces some of the new advanced functionality of PHP 5's OOP features and the author covers concepts like abstract classes, interfaces, and exceptions. One thing that I find really great about this book is that almost everything is explained with examples (and many times understandable and useful examples!). It can be hard to understand certain concepts, but a good example really nails it.
In chapter five the author explains some concepts which can be used to programmatically get information about classes. A few regular functions are explained (like the get_class() function), but the biggest part of this chapter is spent on discussing the Reflection API, which is something new in PHP 5. Although not everything is explained, the most important features of the Reflection API are shown, with examples to match of course.
Chapter six is the first chapter that moves into class design, and here's where it starts to get interesting. First the concept of 'class design' and how OOP differs from procedural code is discussed, and things like class scope, polymorphism, composition, aggregation are explained. This is a key chapter, and it's likely you won't understand all of it immediately, although the author does his best to explain it all.