定制 reliv/zf-config-factories 二次开发

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

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

reliv/zf-config-factories

最新稳定版本:4.3.2

Composer 安装命令:

composer require reliv/zf-config-factories

包简介

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']
            ]
        ]
    ],
]

统计信息

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

GitHub 信息

  • Stars: 5
  • Watchers: 10
  • Forks: 3
  • 开发语言: PHP

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2015-10-08