Top 5 Design patterns used with PHP

Design patterns

In this article i will make a list with most used five design patterns used in PHP, based on my experience and other observations from IT PHP community.

So in my opinion most used design patterns in PHP are: MVC(Model-View-Controller), Singleton, Registry, Observer, Factory.

Top 5 design patterns used in PHP:

 

1. MVC (Model-View-Controller)

Is an architectural design pattern that is used in most of recent PHP application. MVC make application easy to standardize, maintained, understand of developers. Also MVC application are easy to improve, or refactoring, because

2. Singleton

Is an creational pattern and maybe most simple to implement and understand. In PHP applications is used to to ensure that some components like models, or db conections, that are called in various points of application will have a single instance during application run time, in order to preserve application resources.

3. Registry

In PHP developers world is mosly considered a replacement for global variables , and permit to store data (variables,arrays, objects) in a place from where you have access to it from any part of application, even if application is coded in OOP style.

4. Observer

Is a software design pattern and in most cases is key part in MVC architectural pattern. It is mainly used to implement distributed event handling systems. In Magento for example it allow even change normal behavevior without need to extend classes, just by passing objects by reference to observers.

5. Factory

Id an creational pattern and provide an interface for creating families of related or dependent objects without specifying their concrete classes.

 

 


Add comment
 
 
 

Comments