Available in the market since March 1st, 2015 and it’s already the number one Amazon best seller in the PHP programming category. Josh Lockhart new book Modern PHP: New Features and Good Practices is tempting to read for any PHP programmer not only to discover new features, but also good practices. In the book, Josh is showing how he’s using PHP in his projects. He’s the creator of the Slim Framework, co-author of the PHP The Right Way free eBook that we previously covered in addition of being a PHP-FIG representative.

The book is 286 pages in three parts and two appendices, with code examples that you can find in the companion code repository https://github.com/codeguy/modern-php.

Part I. Language features

The first part is dedicated to the new features in PHP mainly namespaces, traits, generators, closures, OpCache and the built-in HTTP server. The explanation is very simple and clear, especially if you are discovering these concepts for the first time, or have some misunderstanding of some features and how to use them.

Best thing I’ve found while reading is that Josh do not hesitate to give some tips and tricks on different topics from a page to another. It makes reading even more interesting, however I highly recommend you to play with the companion code in the same time to better understand what you are reading.

Part II. Good practices

If you are already using PHP and creating applications in your own way, or coding style, this part is very important to read. I was previously talking about PHP-FIG and PSRs in PHP Magazine, but in this book you may find a very detailed explanation about these standards.

I’d prefer if there was some more examples explaining the PSR1 for example, instead of putting all information in one page. Real code and pictures are always easy to understand and remember than headlines.

Then the book introduce components, what, why and how to use them. As usual there are lots of great tips that will help you and guide you through the choice of framework or component, and even how to create your own component.

Last chapter in the second part is full of great tips to sanitize, validate and escape your data, how to secure passwords, working with Dates, Times, and Time Zones, working with Databases, multibyte strings, Character encoding, Streams, and finally Errors and Exceptions. A very hearty chapter that you may need a good iced soda to digest !

Part III. Deployment, Testing, and Tuning

You cannot write a modern PHP application using all the good practices, without knowing how to put it in production correctly, and that’s the normal life cycle of a PHP application. The last part talk about different topics related to deployment including the Web Hosting, Provisioning, Tuning your web server, and finally deploy it using different techniques such as Capistrano.

A chapter is dedicated for testing, and it could be in another book : Why, When, What and How. You have to become more familiar with PHPUnit, Travis CI … Followed by another chapter for Profiling, including tools and techniques to profile your PHP application if you notice any performance issue.

Next chapter is about HHVM and Hack, and I find this part off-topic unless you have Facebook or Wikipedia like website. Personally I’d rather stop at the third page, instead of writing 25 pages.

Finally a whole chapter about the great PHP community !

appendices

The book finish with two appendices, the first one about installing PHP on Linux, OS X, and Windows, and the second one about creating a local development environment using Vagrant. In case you don’t have the environment ready, you can follow the instructions provided to be able to practice techniques discussed inside the book.

Conclusion

Overall it’s a great book, up-to-date with latest tools and techniques used today in PHP applications development. You can buy “Modern PHP” from Amazon Paperback for $24.07 (price may vary), or the Kindle format for $14.49 only.

LEAVE A REPLY

Please enter your comment!
Please enter your name here