Factory Pattern in PHP

The factory pattern is one of the most commonly used design patterns, something you’ll definitely be glad to have in your toolbox. It’s also pretty simple to get to grips with and start reaping the benefits.

The purpose of any factory class, is to create and return instances of other classes, just like a real world factory creates products. There are two types of factory design patterns. One is called the factory method and the other is called an abstract factory. There is another not official pattern called simple factory. All are described in detail below. Let’s get going.

Continue reading