承接 decodelabs/pandora 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

decodelabs/pandora

最新稳定版本:v0.4.1

Composer 安装命令:

composer require decodelabs/pandora

包简介

Potent PSR-11 depdency injection container

README 文档

README

PHP from Packagist Latest Version Total Downloads GitHub Workflow Status PHPStan License

PSR-11 dependency injection container

Pandora offers a simple, powerful and flexible dependency injection and instantiation system to used as the core of your application.

Installation

This package requires PHP 8.4 or higher.

Install via Composer:

composer require decodelabs/pandora

Usage

Instantiate a new Container to keep your important objects organised:

use DecodeLabs\Pandora\Container;

$container = new Container();

Bind instances or classes to interfaces and retrieve them when you need them:

use My\Library\CoolInterface;
use My\Library\CoolImplementation; // Implements CoolInterface

// Instance
$container->bind(CoolInterface::class, new CoolImplementation());
$imp = $container->get(CoolInterface::class);

// Will only bind if CoolInterface has not been bound before
$container->tryBind(CoolInterface::class, new OtherImplementation()); // Will not bind
$imp = $container->get(CoolInterface::class);

// Bind a factory
$container->bind(CoolInterface::class, fn() => new CoolImplementation());

Retrieval

Parameters can be passed to constructors of implementation classes:

$imp = $container->getWith(CoolInterface::class, ['list', 'of', 'params']);

// Or inject parameters for later:
$container->inject(CoolInterface::class, 'paramName', 'paramValue');
$imp = $container->get(CoolInterface::class);

Access the binding controllers:

$binding = $container->getBinding(CoolInterface::class);

Licensing

Pandora is licensed under the MIT License. See LICENSE for the full license text.

统计信息

  • 总下载量: 20.95k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 5
  • 点击次数: 1
  • 依赖项目数: 3
  • 推荐数: 0

GitHub 信息

  • Stars: 5
  • Watchers: 2
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-05-10

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固