This library is a Singleton (anti)pattern implementation using a Traits with a support for an Object Inheritance and passing parameters to the constructor.
composer require piotrpress/singleton
require __DIR__ . '/vendor/autoload.php';
use PiotrPress\Singleton;
class ExampleParent {
use Singleton;
}
class Example extends ExampleParent {
protected function __construct( $arg ) {}
}
Example::getInstance( 'arg' );
PHP >= 7.4
version.