Code Area PHP

Factory Method Design Pattern in PHP

Factory method design pattern is the most common design pattern in software engineering. It’s deals with creating object of a class without specified the class name. Just simply think there is a factory of creating object of other classes.

For example:

We can see there is two different classes, one is Student and another is StudentFactory.  StudentFactory is the factory of creating object of Student class. StudentFactory has a method called create() which used to return the object of Student class. So that we can easily create object of Student class from StudentFactory Class. These are the basic concept of Factory method design pattern in PHP.