reliv/zf2-factories-as-configuration 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

reliv/zf2-factories-as-configuration

最新稳定版本:4.3.2

Composer 安装命令:

composer require reliv/zf2-factories-as-configuration

包简介

Configurable DI for the ZF service manager. Modeled after Symfony 2's DI config files.

README 文档

README

Build Status

Zend Framework Config Factories

Factory classes are tedious. Factory closures have performance issues. Try this module to use factory config arrays instead. The config structure was modeled after Symfony 2 services.yml files. This package is a module for ZF2, ZF3, and Zend-Expressive.

// Example of constructor injection with the service name being the same as its class name:
'service_manager' => [
    'config_factories' => [
        'App\Email\EmailService' => [
            'arguments' => [
                'Name\Of\A\Service\I\Want\To\Inject',
                'Name\Of\A\AnotherService\I\Want\To\Inject'
            ],
        ]
    ]
]

Example usage with all options:

// Use 'dependencies' instead of 'service_manager' here if using Zend Expressive
'service_manager' => [

    // This is a special config key that zf-config-factories reads.
    'config_factories' => [
    
        // This is the name of the service that we are defining.
        'EmailTemplateApi' => [
        
            /**
             * This is the service's class name.
             * Not required if the service's name is the same as its class name.
             */
            'class' => 'App\Controller\EmailTemplateApiController',
            
            /**
             * This is an array of service names that the class's constructor takes.
             * Not required if the service's constructor takes no arguments.
             * Not compatible with the 'factory' option (see below)
             */
            'arguments' => [
                'Name\Of\A\Service\I\Want\To\Inject',
                'Name\Of\A\Service\I\Want\To\Inject2',
                'Name\Of\A\Service\I\Want\To\Inject3',
                'Name\Of\A\Service\I\Want\To\Inject4',
                ['literal' => 'aLiteralValueNotAService'],
                ['from_config' => 'keyOfValueFromZfConfigIWantToReadAndInjectHere'],
                ['from_config' => ['path','to','a','deep','nested','zf','config','key']],
                'Name\Of\A\Service\I\Want\To\Inject5',
            ],
            
            /** 
             * This is an array of setters to call mapped to service names to inject into each setter.
             * Not required if your service has no setters.
             */ 
            'calls' => [
                ['setFunService', ['Name\Of\Another\Service\I\Want\To\Inject']],
                ['setAnotherFunService', ['Name\Of\Another\Service\I\Want\To\Inject']]
            ],
            
             /**
             * Zend-Expressive style factory which is an invokable class
             * 
             * Not required if your service has no factory.
             * Not compatible with the 'arguments' option (see above)
             */ 
            'factory' => 'FunModule\FactoryClassName',

            /** 
             * Symfony style factory that is a service itself.
             *
             * Not required if your service has no factory.
             * Not compatible with the 'arguments' option (see above)
             */ 
            'factory' => [
                ['FunModule\FactoryServiceName', 'createEmailTemplateApi']
            ]
        ]
    ],
]

统计信息

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

GitHub 信息

  • Stars: 4
  • Watchers: 9
  • Forks: 4
  • 开发语言: PHP

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2015-04-24