定制 chubbyphp/chubbyphp-laminas-config-factory 二次开发

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

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

chubbyphp/chubbyphp-laminas-config-factory

最新稳定版本:1.5.0

Composer 安装命令:

composer require chubbyphp/chubbyphp-laminas-config-factory

包简介

README 文档

README

CI Coverage Status Mutation testing badge Latest Stable Version Total Downloads Monthly Downloads

bugs code_smells coverage duplicated_lines_density ncloc sqale_rating alert_status reliability_rating security_rating sqale_index vulnerabilities

Description

An abstract service factory for the laminas/laminas-servicemanager and any other dependency injection container who's been able to handle it's config, like chubbyphp/chubbyphp-container via chubbyphp/chubbyphp-laminas-config and many (Aura.Di, Pimple, Auryn, Symfony, PHP-DI) more.

The original concept of this abstract service factory is by @DASPRiD used in dasprid/container-interop-doctrine which was handed over to roave/psr-container-doctrine.

Small adjustments and the possibility to use the concept as a basis for all service factories led me to make it available as an independent repository.

Requirements

Installation

Through Composer as chubbyphp/chubbyphp-laminas-config-factory.

composer require chubbyphp/chubbyphp-laminas-config-factory "^1.5"

Usage

<?php

declare(strict_types=1);

namespace MyProject\Factory;

use Chubbyphp\Laminas\Config\Factory\AbstractFactory;
use MyProject\Service\ServiceA;
use MyProject\Service\ServiceB;
use MyProject\Service\ServiceC;
use Psr\Container\ContainerInterface;

final class ServiceAFactory extends AbstractFactory
{
    public function __invoke(ContainerInterface $container): ServiceA
    {
        return new ServiceA(
            $this->resolveConfig($container->get('config')['serviceA'] ?? []),
            $this->resolveDependency($container, ServiceB::class, ServiceBFactory::class),
            $this->resolveDependency($container, ServiceC::class, ServiceCFactory::class)
        );
    }
}

/** @var ContainerInterface $container */
$container = ...;

// without name
$serviceA = (new ServiceAFactory())($container);

// with name
$serviceA = [ServiceAFactory::class, 'default']($container);

Copyright

2025 Dominik Zogg

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-09-05