smysloff/singleton-trait

PHP 单例特质,用于创建单例类

0.9.0 2021-07-26 20:49 UTC

This package is auto-updated.

Last update: 2024-09-27 04:31:08 UTC


README

PHP 单例特质,用于不同类中。

创建

use \Smysloff\Traits\Singleton;

require "vendor/autoload.php";

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

    // Put your code below
}

使用

$example = Example::getInstance();

安装

composer require "smysloff/singleton-trait"

参考