Registry / utility / wpsmith-singleton

wpsmith-singleton

JSON →
library1.0.4phppackagistunverified

PHP Singleton Class for implementing the singleton pattern correctly in PHP.

composer require wpsmith/singleton
INSTALL
IMPORT
SIG · WPSMITH-SINGLETON
W
wpsmith-singleton
utilityphpv1.0.4
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Singleton
use WPSmith\Singleton;

Extend the Singleton class and retrieve the single instance.

use WPSmith\Singleton; class MySingleton extends Singleton { protected function init() { // Initialization code here } } $instance = MySingleton::get_instance();
Debug
Known issues
gotchaSingleton pattern can hinder testability and introduce hidden dependencies.
fix
Consider using dependency injection instead of singletons for better testability.
affects: >=1.0.0
Upgrade
Version history
1.0.4latest on Packagist
Audit
Dependencies

No dependency data recorded yet.

Agent activity
31 hits · last 30 days
node
28
Resources
wpsmith-singleton — pip install wpsmith-singleton · libregistry