Wednesday, March 24, 2010

PHP in Action review

PHP in Action: Objects, Design, AgilityPHP in Action is a hands-on PHP book written by Dagfinn Reiersol, Marcus Baked and, most notably, Chris Shiflett. PHP in Action is maybe the only PHP-specific books which bridges typical PHP topics, such as forms and database handling, to object-oriented design. It is very rare to encounter a book like this, which teaches object-oriented programming from a non naive point of view (How do I write those "classes?") in the PHP environment. PHP is still catching up with other languages in this field and many developers can only benefit from improving their modelling skills and design practices.

As I said, this book is PHP-specific; though, many other titles proclaim they're teaching object-oriented PHP on their covers, while the only touched topics are public and private fields, and how to extend classes with inheritance (if that seems normal to you, read this book.) Many publishers jumped on the bandwagon of PHP 5 and proposed books focused on the language constructs instead of the things you can build with them.
PHP in Action is a bit different. For example, it includes some of the SOLID principles and examples of their application in PHP code, without too many assumptions about the overall knowledge of the reader. The most important Design Patterns are explained, with an eye to the native support offered by PHP 5 (SPL).
Advanced techniques (for the average developer) are also introduced, such as refactoring, unit testing and Test-Driven Development. By no means this is an in-depth read on these topics, but the average developer which has a deep understanding of the PHP technology (but not of OO as a decent support was introduced only a few years ago in the language) will find this book useful to start upgrading his skills to the next level. I think this is a common situation, and was also mine; if I had found this book previously, my journey would have been simpler as I wouldn't have had to translate knowledge from Java books. I hope these advanced parts will become a standard in the future.
That said, there is really no PHP book that describes in full depth object-oriented design. There are specific books on object-oriented development, which are very long and insightful and still not complete. These books usually choose Java for their code samples (or C++ if they're very old); you may want to refer to different titles for pure object-oriented learning.

About the material provided, the code samples are inserted in each chapter, and are also refactored while  iterative development takes place. There are many small Uml diagrams to help the reader understand what's going on - mainly class and sequence diagrams. Highlighting of relevant code and changed lines is the norm, along with ordered explanation lists linked to different point of the code samples that substitute intrusive comments.

The level of the book is adequate for the intermediate coder, thus I found it easy to read. Nevertheless, it is a good panoramic of the PHP landscape in term of the transition to object-oriented programming. The first edition is from 2007, and it is not outdated; though, you may consider using a framework to provide many of the infrastructure seen in the book, which is provided more for teaching than actual every day usage.

Some of the links in this post are affiliate links.

10 comments:

Anonymous said...

merely curious but why are you reviewing a three year old book ?

There does not seem to be a second edition available

Giorgio said...

Because there is no more recent book that treats extensively OO in PHP.

Anonymous said...

how about

PHP Objects, Patterns and Practice, Third Edition

http://www.amazon.com/PHP-Objects-Patterns-Practice-Third/dp/143022925X/ref=dp_ob_title_bk

which is already on its third edition - well due may 20th

or this one
Pro PHP: Patterns, Frameworks, Testing and More

not criticizing, merely curious

Giorgio said...

About the first, I read the second edition (which has not the "Pro" prefix) and there were no mentions of TDD, nor refactoring. It was not bad, but has no modelling examples. In PHP in Action, the authors write a DateAndTime management class from scratch, and I had never seen SOLID principles explained in PHP before.

For the second, I read the index on Amazon and was astonished:
Part 1, OOP and Patterns: divided in Singleton and Factory patterns, Exceptions, What's new in PHP 6. End of the patterns.
Part 2: Testing and documentation and Reflection API.
Part 3: SPL.
Part 4: MVC and Zend Framework.
Part 5: Ajax (short).
This is an example of a book that overpromises, imho. :)

Anonymous said...

What does it matter how old a book is if the content is still relelvant? PHP In Action is a *great* book and helped me a lot when I first moved to PHP (from a static language background)

Anonymous said...

Hey Giorgio, you should write an advanced OOD/OOP book - I would buy it for sure!

Giorgio said...

Well, my free ebook on testing is a good start. Ease of testing is an important design guideline. :)

Anonymous said...

my last comment seems to have not appeared.


I was not complaining, i was merely curious as i initially said.

Giorgio said...

There is no moderation before comments go live - if something went wrong you can repost it if you feel like it.

Anonymous said...

ПРИОР Строительно-инвестиционная фирма предлагает :
- комплексный ремонт квартир и офисов по самым низким ценам
- Евроремонт квартир ,коттеджей и также офисных помещений с любым обьемом работ
- капитальный ремонт, реставрация промышленых также жилых зданий
- капитальный ремонт и перестройка торговых, игровых также развлекательных центров,медицинских,финансовых и правительственных учреждений.
- все виды строительно-инженерных, отделочных работ,покраска,побелка,стяжка,поклейка обоев ,плитка и пр.
- контроль и также гарантия качественного исполнения работ,
Любая форма оплаты
http://rem.rv.ua

ShareThis