Learning PHP Design Patterns, William Sanders, O’Reilly 2013
Web programmers will want to read this book, in particular users of PHP.
To succeed in larger projects you need some structure, and PHP Design Patterns proposes that you use the same high level structures that have been useful to C++ and Java programmers for many years. The author read the ‘Gang of 4’ book (Gamma, Helm, Johnson and Vlissides), and has interpreted it in the PHP context. He starts with a refresher on Object Oriented programming, which will be easy reading for anyone with knowledge of OO. Then he shows how to make best use of the OO features in PHP since version 5, referencing the most useful design patterns. Inheritance, polymorphism, encapsulation are all discussed with example code in php.
Returning to the Vtiger example, when the code uses some OO structure, it is often not clear what pattern is in use. A file should start with comments on what design pattern is being used, and if not, then a discussion of how the objects are used. If the designers had started with the common design patterns from this book, then it would all be more clear.
I want you to read this well written book in the hopes that the next php projects I need to enhance will be well structured and easier to work with. This means you! Why would you not just Google The Fine Thing (GTFT)? Because then you get snowed with poorly edited info. Read the book for a well organized presentation of the few important, common patterns.
Disclaimer: I read the electronic version of the book, on a smartphone. The reading experience is quite different from bound, paper books with pros and cons. Disclaimer 2: I got the book through the O’Reilly blogger program.
Unfortunately, the OPL does not have PHP Design Patterns yet. 350 pages.