2017 © Pedro Peláez
 

library easy-config

Zend Framework 2 (zf2) module to retrieve specific module options and provides some abstract factories to create easily instances depending on configuration

image

sandrokeil/easy-config

Zend Framework 2 (zf2) module to retrieve specific module options and provides some abstract factories to create easily instances depending on configuration

  • Tuesday, August 25, 2015
  • by sandrokeil
  • Repository
  • 1 Watchers
  • 12 Stars
  • 3,122 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 6 Versions
  • 0 % Grown

The README.md

EasyConfig module for Zend Framework 2

You want to configure your factories via your module config?, (*1)

You want to configure option classes via module config for your plugin manager?, (*2)

You want to add other services via module config to a factory?, (*3)

This module comes to the rescue!, (*4)

Build Status Scrutinizer Quality Score Coverage Status HHVM Status SensioLabsInsight Latest Stable Version Dependency Status Total Downloads License, (*5)

EasyConfig provides some abstract factories and some interfaces to easily create instances depending on configuration or retrieve specified module options., (*6)

  • Well tested. Besides unit test and continuous integration/inspection this solution is also ready for production use.
  • Great foundations. Based on Zend Framework 2
  • Every change is tracked. Want to know whats new? Take a look at CHANGELOG.md
  • Listen to your ideas. Have a great idea? Bring your tested pull request or open a new issue.

You should have coding conventions and you should have config conventions. If not, you should think about that., (*7)

The module config keys should have the following structure module.scope.name. A common configuration looks like that:, (*8)

return array(
    'doctrine' => array(
        'connection' => array(
            'orm_default' => array(
                'driverClass' => 'Doctrine\DBAL\Driver\PDOMySql\Driver',
                'params' => array(...)
            )
        )
    )
);

So doctrine is the module, connection is the scope and orm_default is the name. After that the specified instance options follow. With AbstractConfigurableFactory we can easily access to these options also with an option class and mandatory options check. See docs for a detailed explanation., (*9)

use Sake\EasyConfig\Service\AbstractConfigurableFactory;
use Sake\EasyConfig\Service\OptionsClassInterface;
use Sake\EasyConfig\Service\MandatoryOptionsInterface;
use Zend\ServiceManager\FactoryInterface;
use Zend\ServiceManager\ServiceLocatorInterface;

class MyDBALConnectionFactory extends AbstractConfigurableFactory implements FactoryInterface, OptionsClassInterface, MandatoryOptionsInterface
{
    public function createService(ServiceLocatorInterface $serviceLocator)
    {
        // get option class for doctrine.connection.orm_default
        // dont implement OptionsClassInterface to get an array of options
        $options = $this->getOptions($serviceLocator);

        // so you can do
        $pdo          = $options->getPdo();
        $driverClass  = $options->getDriverClass();
        $wrapperClass = $options->getWrapperClass();

        // create your instance

        return $instance;
    }

    /**
     * Returns a list of mandatory options which must be available
     *
     * @return array
     */
    public function getMandatoryOptions()
    {
        return array(
            'driverClass',
            'params',
        );
    }

    /**
     * Return the option class name (fcqn) where options are injected via constructor
     *
     * @return string
     */
    public function getOptionsClass()
    {
        return '\DoctrineORMModule\Options\DBALConnection';
    }

    /**
     * Module name
     *
     * @return string
     */
    public function getModule()
    {
        return 'doctrine';
    }

    /**
     * Config scope
     *
     * @return string
     */
    public function getScope()
    {
        return 'connection';
    }

    /**
     * Config name
     *
     * @return string
     */
    public function getName()
    {
        return 'orm_default';
    }
}

Installation

Installation of this module uses composer. For composer documentation, please refer to getcomposer.org., (*10)

Put the following into your composer.json, (*11)

{
    "require": {
        "sandrokeil/easy-config": "~1.0"
    }
}

It is not necessary to add this module to your config/application.config.php., (*12)

Documentation

You can find documentation about the usages of factories at the following links:, (*13)

The Versions

25/08 2015

dev-develop

dev-develop https://github.com/sandrokeil/EasyConfig

Zend Framework 2 (zf2) module to retrieve specific module options and provides some abstract factories to create easily instances depending on configuration

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

service config zf2 zend framework service manager factory options

27/12 2014

dev-master

9999999-dev https://github.com/sandrokeil/EasyConfig

Zend Framework 2 (zf2) module to retrieve specific module options and provides some abstract factories to create easily instances depending on configuration

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

service config zf2 zend framework service manager factory options

24/09 2014

1.3.0

1.3.0.0 https://github.com/sandrokeil/EasyConfig

Zend Framework 2 (zf2) module to retrieve specific module options and provides some abstract factories to create easily instances depending on configuration

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

service config zf2 zend framework service manager factory options

29/04 2014

1.2.0

1.2.0.0 https://github.com/sandrokeil/EasyConfig

Zend Framework 2 module to retrieve specific module options and provides some abstract factories to create easily instances depending on configuration

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

service config zf2 zend framework service manager options

03/04 2014

1.1.0

1.1.0.0 https://github.com/sandrokeil/EasyConfig

Zend Framework 2 module to retrieve specific module options and provides some abstract factories to create easily instances depending on configuration

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

service config zf2 options

25/11 2013

1.0.0

1.0.0.0 https://github.com/sandrokeil/EasyConfig

Easy config provides some abstract factories to easily create instances depending on configuration or retrieve specified module options.

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

service config zf2 options