zf-hipsters/zfh-abstract-factory 问题修复 & 功能扩展

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

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

zf-hipsters/zfh-abstract-factory

Composer 安装命令:

composer require zf-hipsters/zfh-abstract-factory

包简介

A simple module that removes the requirement to setup invokables and factories for services and controllers..

README 文档

README

A simple module that removes the requirement to setup invokables and factories for services and controllers.

There is no requirement to use aliases that make your code inconsistant, just use the full namespace and the abstract will find it and instantiate it when required.

This module is aimed at saving time which would otherwise be spent on configuration.

Installation

  1. Add the following requirement to your projects composer.json file.

Within the "require" section:

"zf-hipsters/abstract-factory": ">=0.9"
  1. Open up your command line and run
php ./composer.phar update
  1. Add 'ZfhAbstractFactory' to your /config/application.config.php modules

Route Example

Without ZfhAbstractFactory being enabled, you need to register your controllers within configuration such as:

'controllers' => array(
    'invokables' => array(
        'Album\Controller\Album' => 'Album\Controller\AlbumController',
    ),
),

When ZfhAbstractFactory is enabled, you can avoid registering controllers in this way if you use the FQN of the controller in your route.

Note: the FQN of the controller has been used.

'router' => array(
        'routes' => array(
            'home' => array(
                'type' => 'Zend\Mvc\Router\Http\Literal',
                'options' => array(
                    'route'    => '/',
                    'defaults' => array(
                        'controller'    => 'Application\Controller\IndexController',
                        'action'     => 'index',
                    ),
                ),
            ),�
        )
);

Another example with dynamic with fixed controller and a dynamic action.

'smurf' => array(
    'type' => 'Zend\Mvc\Router\Http\Segment',
    'options' => array(
        'route'    => '/smurf[/:action]',
        'controller' => 'Application\Controller\SmurfController',
        'defaults' => array(
            'action' => 'index',
        ),
    ),
),

ServiceManager Example

In your controller file

$this->getServiceLocator()->get('Application\Service\MyService');

Calling a factory

$this->getServiceLocator()->get('Application\Service\MyServiceFactory');

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: Unknown
  • 更新时间: 2013-10-21