Skip to content

A lightweight PHP implementation of the Design Pattern Singleton using trait.

License

Notifications You must be signed in to change notification settings

BlackbitDevs/SingletonPatternPHP

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Singleton Pattern

Scrutinizer Code Quality Code Climate

Description

A lightweight PHP implementation of the Design Pattern Singleton using trait. Just one class and no dependencies.

Usage

Create your class

require "vendor/autoload.php";

class Example
{
    // You need to use the trait here
    use \ByJG\DesignPattern\Singleton;

    // Put your code below
}

REMEMBER: Your class cannot have a public constructor. If it is necessary, use a private or protected constructor instead. Singleton classes does not have arguments in the constructor;

Use your class

$example = Example::getInstance();

Install

Just type: composer install "byjg/singleton-pattern=1.0.1"

References

About

A lightweight PHP implementation of the Design Pattern Singleton using trait.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.0%