使用PHP在工作场所使用的设计模式的频率

I read a book awhile back called PHP Design Patterns and Practice, and ever since then I have been using design patterns whenever I think they are needed. However it just occurred to me that maybe most companies do not use design patterns very often for PHP, or at all. What I was wondering is, do most companies use design patterns to help improve code flexibility? And if so, what are the best design patterns to learn for PHP?

Thanks for any help on this, Metropolis

Thanks for all of your great answers on this!
The conclusion I can take from this is: Patterns are used in almost all work places with PHP, and the most common ones need to be understood and memorized. Also, the MVC architectural pattern is very important and everyone will expect you to know it.

In my experience, the answer is: very often. Almost every place I've worked at uses design (and architectural) patterns. These are larger projects and it helps in implementation, maintenance and analysis to use known solutions to common problems.

You'll want to learn all the biggies (because you'll both use and run into them) starting with: Factory, Singleton, Observer, Strategy.

MVC is an architectural pattern that you should know well.

Practically speaking, design patterns are good ideas should be implemented but are most important when you've got to normalize the skill level of multiple engineers working on the same systems. Consider the situation where you may have 3 or 4 engineers of varrying skill level working on the same project, touching each others files and interacting with code that they may not have written or know the background on. One way that design patterns and common practices help is to keep everyone on the same level and enforce commonality across the code base.

Probably the most commonly used design patterns are the singleton and the factory patterns. I've recently found the observer pattern extremely useful for triggering events when an object is changed in some way (similar to database triggers); and I find the Fluid Interface pattern particularly useful as well, allowing a chain of method calls. All of those are used regularly within my workplace.

I can only speak from my experience, but most of the places I've worked have done a good job of learning and implementing design patterns/best practices in the workplace. Whether a company follows best practices or not is really a question of corporate/dev culture and the team's level of expertise.

As far as what patterns are best, you can never go wrong with dependency injection, one of my faves. IMHO, the best patterns to use are those that best fit the use case you're addressing.

Good luck!

For any non-trivial OO project design patterns are not an option, they are the only way to go. That is if you want to keep your sanity as the codebase evolves and expands. From what I've seen, companies that work on PHP eventually decide to invest in some sort of framework. Modern PHP frameworks are showcases for design patterns, especially the basics like Factory and Singleton. Properly used they can result in very extensible code.

The bad old days of include()-infested non-OO PHP4 code are thankfully behind us.