nolikein/singleton

A singleton design pattern

1.0.0 2020-10-31 16:57 UTC

This package is auto-updated.

Last update: 2024-06-29 04:59:19 UTC


README

PHP Packagist version Packagist License Gitlab pipeline status

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.