piotrpress/singleton

这个库是一个使用 Traits 的 Singleton(反模式)实现,支持对象继承和向构造函数传递参数。

v7.0.0 2024-09-15 20:35 UTC

This package is auto-updated.

Last update: 2024-09-15 20:35:57 UTC


README

这个库是一个 Singleton(反模式)实现,使用 Traits,支持对象继承和向构造函数传递参数。

安装

composer require piotrpress/singleton

用法

require __DIR__ . '/vendor/autoload.php';

use PiotrPress\Singleton;

class ExampleParent {
    use Singleton;
}

class Example extends ExampleParent {
    protected function __construct( $arg ) {}
}

Example::getInstance( 'arg' );

要求

PHP >= 7.4 版本。

许可证

GPL3.0