michaelspiss/singleton
Composer 安装命令:
composer require michaelspiss/singleton
包简介
A trait to implement the Singleton design pattern without any dependencies.
README 文档
README
A trait to implement the Singleton design pattern without any dependencies.
Why?
There already are plenty other singleton packages, so why another one? Simply, because most of those packages implement a factory, rather than a singleton pattern. This and many more things bothered me about them, so here is a simple, dependency-free and fully tested singleton.
Installation
$ composer require michaelspiss/singleton
Basic Usage
One line is enough to turn a class into a singleton:
<?php class StorageProvider { use MichaelSpiss\DesignPatterns\Singleton; ... }
To retrieve the singleton instance, simply call
$singleton = StorageProvider::getInstance();
Read more
There really isn't much left to say, but if you want to know more about constructors for singletons or forbidden actions you should check out the wiki!
PHP Requirements
- PHP >= 5.4
License
MIT
统计信息
- 总下载量: 14
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2017-04-18