承接 b2pweb/bdf-instantiator 相关项目开发

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

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

b2pweb/bdf-instantiator

最新稳定版本:v1.2.0

Composer 安装命令:

composer require b2pweb/bdf-instantiator

包简介

Bdf Instantiator component

README 文档

README

A basic object instantiator.

build codecov Packagist Version Total Downloads

Install via composer

$ composer require b2pweb/bdf-instantiator

Usage Instruction

Basic usage when resolving from container definition.

use Bdf\Instantiator\Instantiator;
use Psr\Container\ContainerInterface;
use Psr\Log\LoggerInterface;

/** @var ContainerInterface $container */
$container->add(Logger::class, LoggerInterface::class);

$instantiator = new Instantiator($container);
$instantiator->make(LoggerInterface::class);

The instantiator resolve the dependencies of a method based on container definitions.

use Bdf\Instantiator\Instantiator;
use Psr\Container\ContainerInterface;
use Psr\Log\LoggerInterface;

class Foo
{
    public $logger;
    
    /**
     * Foo constructor.
     * 
     * @param LoggerInterface $logger  
     */
    public function __construct(LoggerInterface $logger)
    {
        $this->logger = $logger;
    }
}

/** @var ContainerInterface $container */
$container->add(Logger::class, LoggerInterface::class);

$instantiator = new Instantiator($container);
$foo = $instantiator->make(Foo::class);

var_dump($foo->logger); // Logger

License

Distributed under the terms of the MIT license.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-12-18