PHP in Action, a Review

[amazon_link id=”1932394753″ target=”_blank” container=”” container_class=”” ]PHP in Action[/amazon_link] is all about using PHP. It is not about learning PHP. In the book, you’ll study practical ways of applying software patterns to real life situations. It is not a book for beginning PHP programmers, but it is a treasure trove for those looking for good ways to solve common problems in web application development.

PHP

You may or may not like to hear this, but PHP is the language of the web. Where JavaScript is the de facto choice for client side programming, PHP is ubiquitous on the servers of small businesses everywhere, but it is also used for many large web applications. Many other programming languages only come into play once a website is established and management decides something more “enterprisy” is needed.

The trouble with PHP is, that it makes it incredibly easy to shoot yourself in the foot. Global variables are frowned upon pretty much anywhere, PHP has a special keyword for them. Many popular PHP applications actually rely on them.

However, in the hands of a skilled PHP developer, the language is an incredible tool for rapid development. Dynamic programming and duck typing allow a freedom that any Java developer can only dream of. Add to this the availability of very cheap hosting and you’ve got a bootstrapper’s dream.

PHP in Action

This is where “[amazon_link id=”1932394753″ target=”_blank” container=”” container_class=”” ]PHP in Action[/amazon_link]” comes into the picture. It shows you how to apply modern software development and design techniques in PHP. In 4 parts you’ll learn:

  • How you can create object oriented programs in PHP
  • How to properly and automatically test your application
  • How to create secure, extendible and bug-free web interfaces
  • And finally, how to get everything into and out of the database

You’ll notice that there is no chapter on how to program PHP. You either need to know the PHP basics, or you’re going to need to fill the gaps by lots of Google. Nothing I would recommend to a starting programmer.

Lead by Example

Most of the chapters use small pieces of code from larger projects. Those examples work very well, because it clearly shows you why the presented patterns are useful and what pain points they solve. Starting from a badly designed program, the author gradually introduces the concepts and immediately applies them so you can see how the architecture of the application improves.

Depending on your knowledge of PHP and software patterns in general, you will need more or less time to truly get the advantage. In most cases you will want to experiment with them.

So take your time and work on some small hobby application during the read.

Frameworks and Libraries

Quite frequently, PHP libraries are used in the code examples. Most of them are only mentioned incidental, except for SimpleTest which is used throughout the chapters on testing. In most chapters, enough information is given to get started with the libraries immediately. However the database chapters were a bit too short in this regard. A few libraries are used (eg. Creole) and code fragments are shown, but the libraries’ homepages and documentation are essential to really get started using them.

In general, the later chapters seemed to have been kept shorter and less in depth than the earlier ones. I’m not sure if this was intended, but it didn’t bother me, except for the chapter 14 on composite views and templating. In my opinion, this was the only chapter where the examples were too incomplete and the overview was missing. It was very unclear how the different parts fit together to form a templated application.

But that is my only criticism with the book.

Conclusion

If you know a little PHP or you have a good grip of another language and are feeling adventurous, [amazon_link id=”1932394753″ target=”_blank” container=”” container_class=”” ]PHP in Action[/amazon_link] is the book for you. Clear and concise examples show how to apply modern software development techniques and patterns.