PHP code example of web6 / singleton

1. Go to this page and download the library: Download web6/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/ */

    

web6 / singleton example snippets




class App {

    use \W6\Singleton\SingletonTrait;

    public $message = 'Not inited';

    protected function init() {
        $this->message = 'Inited';
    }
}

$app = App::instance();
echo $app->message;