dcsimg
October 18, 2018
Hot Topics:

Implement the Singleton Pattern in PHP Without Taking a Performance Hit

  • November 26, 2010
  • By Glen Kunene
  • Send Email »
  • More Articles »

Part of the well-known Gang of Four (GoF) design patterns, the Singleton pattern calls for restricting the instantiation of a class to one object. Implemented correctly in PHP, this pattern can facilitate powerful and robust applications.

In her PHPBuilder article, Implementing the Singleton Pattern in PHP 5, Octavia Anghel explains how to implement the Singleton pattern in different ways for different purposes in PHP 5. She writes:

The Singleton pattern fits well when you manage a shared resource -- a printer, a file manager, a database connection, loggers, and so on -- because your application should have only a single instance in order to avoid conflicting requests for the same resource and to minimize performance issues.

Integrating design patterns into your PHP applications can lead to performance issues if you don't do it right. Octavia demonstrates the proper way to implement the Singleton pattern in PHP.

 

Read the full story at PHPBuilder:
Implementing the Singleton Pattern in PHP 5



Originally published on https://www.developer.com.


Comment and Contribute

 


(Maximum characters: 1200). You have characters left.

 

 


Enterprise Development Update

Don't miss an article. Subscribe to our newsletter below.

By submitting your information, you agree that developer.com may send you developer offers via email, phone and text message, as well as email offers about other products and services that developer believes may be of interest to you. developer will process your information in accordance with the Quinstreet Privacy Policy.

Sitemap

Thanks for your registration, follow us on our social networks to keep up-to-date