定制 web6/singleton 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

web6/singleton

Composer 安装命令:

composer require web6/singleton

包简介

PHP Singleton design pattern

README 文档

README

Implementation of singleton design pattern in PHP5.4+ using a trait.

Install

Install via Composer

$ composer require web6/singleton

Usage

Configure autoload

Configure autoloading by including Composer's generated file :

include_once('vendor/autoload.php');

Create a singleton class

To create a singleton class simply use the W6\Sinfleton\SingletonTrait and move the __construct() logic to the init() method.

class App {

    use \W6\Singleton\SingletonTrait;

    public $message = 'Not inited';

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

Use your class

Anywhere in your application you can request the same instance of the class.

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

统计信息

  • 总下载量: 48
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-3.0-or-later
  • 更新时间: 2019-05-19

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固