1. Go to this page and download the library: Download cse/base-singleton library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
cse / base-singleton example snippets
class ExampleSingleton
{
use SingletonTrait;
...
}
$instance = ExampleSingleton::getInstance();
$instanceName = ExampleSingleton::getInstance('instance_name');
class ModelSingleton
{
use SingletonTrait;
protected $param = 0;
/**
* @param int $param
*/
public function setParam(int $param): void
{
$this->param = $param;
}
/**
* @return int
*/
public function getParam(): int
{
return $this->param;
}
}