PHP code example of hametuha / singleton-pattern
1. Go to this page and download the library: Download hametuha/singleton-pattern 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/ */
hametuha / singleton-pattern example snippets
use Hametuha\SingletonPattern\Singleton;
class SampleSingleton extends Singleton {
private $version = '';
/**
* This method is called inside constructor.
*/
protected function init() {
$this->version = get_wp_version();
}
/**
* Greeting.
*/
public function greet() {
echo 'Hello World!';
}
}
SampleSingleton::get_instance()->greet();
// -> Hello World!
Hametuha\SingletonPatter\BulkRegister::enable( 'Vendor\Library\NameSpace', __DIR__ . '/src/Vendor/Library/NameSpace' );
// => 3(enabled class count)