Last Updated | | Ratings | | Unique User Downloads | | Download Rankings |
2024-07-13 (Yesterday) | | Not yet rated by the users | | Total: 21 This week: 21 | | All time: 11,227 This week: 6 |
|
Description | | Author |
This package can show how to create only one object of class.
It provides a singleton helper class that can store a single object of a given class and return the same object every time it is called to return the singleton.
The package also provides an example class that uses the singleton helper class to ensure that only one object of that class exists. | |
|
|
Innovation award
Nominee: 9x |
|
Example
<?php
use Ahmard\Singleton\Environment;
require_once __DIR__ . '/vendor/autoload.php';
$app = Environment::getInstance()
->setName('Test')
->setEnv('dev')
->setHost('http://localhost');
var_dump(Environment::getInstance()->getAppName());
var_dump(Environment::getInstance()->getAppEnv());
var_dump(Environment::getInstance()->getAppHost());
|
Details
PHP Singleton
Minimal PHP Singleton Demostration
Installation
Clone the repo
git clone https://github.com/ahmard/minimal-singleton.git
Navigate to the cloned repo
cd minimal-singleton
Install Composer packages
composer install
Usage
Run below command to run the example
php entry.php
|
Applications that use this package |
|
No pages of applications that use this class were specified.
If you know an application of this package, send a message to the author to add a link here.