nolikein / singleton
A singleton design pattern
1.0.0
2020-10-31 16:57 UTC
Requires
- php: ^7.3
Requires (Dev)
- phpunit/phpunit: ^9
This package is auto-updated.
Last update: 2023-09-29 02:38:38 UTC
README
Description
This librairy use the singleton design pattern. Thanks to the project of domnikl.
Installation
Use composer, in simple command line:
composer require nolikein/singleton ^1.0.0
Use composer with Docker:
docker run --rm --interactive --tty -v $PWD:/app composer require nolikein/singleton ^1.0.0
Usage
You can include a singleton by 2 means.
1/ Extending the singleton like this:
use Nolikein\Singleton\SingletonClass;
class InheritatedClass extends SingletonClass
//...
2/ Using trait:
use Nolikein\Singleton\SingletonTrait;
class ClassWithTrait
{
use SingletonTrait;
//...
Finally, you can create an instance:
$instance = MyClass::getInstance();
Licence
The project is under lincence MIT.