Legacy Refactor Question: What About Singletons?

By | June 3, 2014

In my talk and my book on refactoring legacy PHP code, one of the early steps is to start removing globals and replace them with dependency injection (not a container, just injecting dependencies by hand.) I addressed the use of the global keyword and the $_GET (et al) superglobals, but I did not address singletons directly. I had a Reddit correspondent ask about singletons recently, and how to refactor away from them; I answered on Reddit, where you can read the full conversation.

3 thoughts on “Legacy Refactor Question: What About Singletons?

  1. Pingback: Moderizing Legacy PHP: From Service Locator To Dependency Injection | Paul M. Jones

Leave a Reply

Your email address will not be published. Required fields are marked *