Arsenal PHP Singleton Trait: Trait to make classes only have singleton objects

Recommend this page to a friend!
  Info   View files Example   View files View files (2)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2020-02-04 (6 months ago) RSS 2.0 feedNot yet rated by the usersTotal: 119 All time: 9,176 This week: 241Up
Version License PHP version Categories
arsenal 1.1Freeware7Language, Design Patterns, PHP 7, Traits
Description Author

This package provides a trait to make classes only have singleton objects.

The trait provides a getter function that initializes an object on the first time a variable of the class is accessed with an instance of the target object that will act as a singleton object for the class.

A setter function will assign the variables of the target object that acts as singleton object for that class.

A constant array can be used to define how to map classes to target classes that will have objects acting as singletons.

Innovation Award
PHP Programming Innovation award nominee
January 2020
Number 4
Singleton is a common design pattern used by many developers to assure that only one object of a class is created even if the software tries to create objects of that class more than once.

This package provides an alternative approach to assure that only one object of a class is created by using PHP constant values to keep track of the objects that are created.

Manuel Lemos
Picture of wim niemans
  Performance   Level  
Name: wim niemans <contact>
Classes: 2 packages by
Country: The Netherlands The Netherlands
Age: 70
All time rank: 4145100 in The Netherlands The Netherlands
Week rank: 719 Up15 in The Netherlands The Netherlands Up
Innovation award
Innovation award
Nominee: 1x

  Files folder image Files  
File Role Description
Plain text file arsenal.php Class singleton factory trait
Accessible without login Plain text file demo.php Example example script

 Version Control Unique User Downloads Download Rankings  
 0%
Total:119
This week:0
All time:9,176
This week:241Up

For more information send a message to info at phpclasses dot org.