定制 jpc/design-pattern 二次开发

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

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

jpc/design-pattern

最新稳定版本:1.1.0

Composer 安装命令:

composer require jpc/design-pattern

包简介

Simple Design Patter integration

README 文档

README

DesignPattern library allow you to simply include design pattern like Singleton or Multiton into your classes.

Installation

Use composer require jpc/design-pattern to install with composer.

How to use

Create the singleton class

Create your class which you want to be a Singleton class.

<?php class MySingletonClass { // Some properties and functions public function __construct($myFristParam, $mySecondParam){ //... } } ?>

Then, add the Singleton trait.

<?php class MySingletonClass { use JPC\DesignPattern\Singleton; // Some properties and functions public function __construct($myFristParam, $mySecondParam){ //... } } ?>

Get the Singleton class

You can simply use the static function getInstance to get singleton instance.

//Some Code $mySingleton = MySingletonClass::getInstance($param1, $param2); //Some Code

For Multiton

The unique difference between Singleton and Multiton is when you get the instance, you have to pass an identifier like that :

//Some Code $myMultiton = MyMultitonClass::getInstance("IDENTIFIER", $param1, $param2); //Some Code

It's allow you to make different instance with different parameters.

Thanks You!

Thanks you for reading and maybe for downloading and use this library! If you have some request, make them and i will code it for you!

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: GPL-3.0
  • 更新时间: 2026-01-04

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固