PHPackages                             sandrokeil/easy-config - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. sandrokeil/easy-config

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

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

1.3.0(11y ago)113.1k11BSD-3-ClausePHPPHP ~5.3

Since Nov 25Pushed 10y ago1 watchersCompare

[ Source](https://github.com/sandrokeil/EasyConfig)[ Packagist](https://packagist.org/packages/sandrokeil/easy-config)[ Docs](https://github.com/sandrokeil/EasyConfig)[ RSS](/packages/sandrokeil-easy-config/feed)WikiDiscussions master Synced 5d ago

READMEChangelog (2)Dependencies (8)Versions (6)Used By (1)

EasyConfig module for Zend Framework 2
======================================

[](#easyconfig-module-for-zend-framework-2)

> You want to configure your factories via your module config?

> You want to configure option classes via module config for your plugin manager?

> You want to add other services via module config to a factory?

> This module comes to the rescue!

[![Build Status](https://camo.githubusercontent.com/022018a8f7c13bb4084e39f9847b8f047dec3ccdd3a4a70e011e6ec1ac117cb6/68747470733a2f2f7472617669732d63692e6f72672f73616e64726f6b65696c2f45617379436f6e6669672e706e673f6272616e63683d6d6173746572)](https://travis-ci.org/sandrokeil/EasyConfig)[![Scrutinizer Quality Score](https://camo.githubusercontent.com/5370f66659a84c9ad0a8b7661f93535dba54df60caa708b72eb2b63442261e25/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f73616e64726f6b65696c2f45617379436f6e6669672f6261646765732f7175616c6974792d73636f72652e706e673f733d63646566313631633134313536653365333665643063653364366664373937396433386439313663)](https://scrutinizer-ci.com/g/sandrokeil/EasyConfig/)[![Coverage Status](https://camo.githubusercontent.com/eda45da10860d7b862ca59ef96db99ba27a7747e2162d3e30346f6db40bc733c/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f73616e64726f6b65696c2f45617379436f6e6669672f62616467652e706e673f6272616e63683d6d6173746572)](https://coveralls.io/r/sandrokeil/EasyConfig?branch=master)[![HHVM Status](https://camo.githubusercontent.com/2d720a645dc192ec2106d8784ee08105318226e17f4969c78d5672df8912b768/687474703a2f2f6868766d2e683463632e64652f62616467652f73616e64726f6b65696c2f656173792d636f6e6669672e737667)](http://hhvm.h4cc.de/package/sandrokeil/easy-config)[![SensioLabsInsight](https://camo.githubusercontent.com/bd7761823f9be5fb2673aeab9c15bede656f784c91b6e1193a87d91a595d4945/68747470733a2f2f696e73696768742e73656e73696f6c6162732e636f6d2f70726f6a656374732f63373039326262652d386463322d343733642d396331332d3631376634316232333735622f6d696e692e706e67)](https://insight.sensiolabs.com/projects/c7092bbe-8dc2-473d-9c13-617f41b2375b)[![Latest Stable Version](https://camo.githubusercontent.com/290fac17e082b0f71a490c1a8d6b88c26144ce63c8064e8922a38589f21a32cb/68747470733a2f2f706f7365722e707567782e6f72672f73616e64726f6b65696c2f656173792d636f6e6669672f762f737461626c652e706e67)](https://packagist.org/packages/sandrokeil/easy-config)[![Dependency Status](https://camo.githubusercontent.com/9be80182cc3b2db80562af761f1470309ed9af6314f2bf513f551ffc43f03c7e/68747470733a2f2f7777772e76657273696f6e6579652e636f6d2f757365722f70726f6a656374732f3533363135633735666530643037323065623030303039652f62616467652e706e67)](https://www.versioneye.com/user/projects/53615c75fe0d0720eb00009e)[![Total Downloads](https://camo.githubusercontent.com/82b2c7a898f57837da158664697dcb25417cbdf62b8a7cc0e5b106932a767d88/68747470733a2f2f706f7365722e707567782e6f72672f73616e64726f6b65696c2f656173792d636f6e6669672f646f776e6c6f6164732e706e67)](https://packagist.org/packages/sandrokeil/easy-config)[![License](https://camo.githubusercontent.com/133db6af03f905ec53201cfbf92c3f73e2d6592c28cb398519c6620c79e14b45/68747470733a2f2f706f7365722e707567782e6f72672f73616e64726f6b65696c2f656173792d636f6e6669672f6c6963656e73652e706e67)](https://packagist.org/packages/sandrokeil/easy-config)

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

- **Well tested.** Besides unit test and continuous integration/inspection this solution is also ready for production use.
- **Great foundations.** Based on [Zend Framework 2](https://github.com/zendframework/zf2)
- **Every change is tracked**. Want to know whats new? Take a look at [CHANGELOG.md](https://github.com/sandrokeil/EasyConfig/blob/master/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.

The module config keys should have the following structure `module.scope.name`. A common configuration looks like that:

```
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](docs/Configurable.md) we can easily access to these options also with an option class and mandatory options check. See [docs](docs/Configurable.md) for a detailed explanation.

```
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)

Installation of this module uses composer. For composer documentation, please refer to [getcomposer.org](http://getcomposer.org/).

Put the following into your composer.json

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

```

It is *not necessary* to add this module to your `config/application.config.php`.

Documentation
-------------

[](#documentation)

You can find documentation about the usages of factories at the following links:

- [Configurable - Get an options class or an array of options and with mandatory options check](docs/Configurable.md)
- [ConstructorOptionConfig - Inject options via constructor](docs/ConstructorOptionConfig.md)
- [OptionHydratorConfig - Inject options with a hydrator](docs/OptionHydratorConfig.md)
- [ServiceConfig - Inject an other service to instance](docs/ServiceConfig.md)
- [ServiceManagerConfig - Inject Options to a service plugin manager](docs/ServiceManagerConfig.md)
- [ServiceOptionConfig - Inject one or more services](docs/ServiceOptionConfig.md)

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity24

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~100 days

Total

4

Last Release

4253d ago

PHP version history (2 changes)1.0.0PHP &gt;=5.3.3

1.1.0PHP ~5.3

### Community

Maintainers

![](https://www.gravatar.com/avatar/58f3428ea5d86dde45a70842c5228d295ec37a493594d484bf1ed2552e85b791?d=identicon)[sandrokeil](/maintainers/sandrokeil)

---

Top Contributors

[![sandrokeil](https://avatars.githubusercontent.com/u/3597436?v=4)](https://github.com/sandrokeil "sandrokeil (20 commits)")

---

Tags

factoryconfigoptionsserviceservice-managerzf2Zend Framework

### Embed Badge

![Health badge](/badges/sandrokeil-easy-config/health.svg)

```
[![Health](https://phpackages.com/badges/sandrokeil-easy-config/health.svg)](https://phpackages.com/packages/sandrokeil-easy-config)
```

###  Alternatives

[symfony/options-resolver

Provides an improved replacement for the array\_replace PHP function

3.2k493.9M1.6k](/packages/symfony-options-resolver)[sandrokeil/interop-config

Provides interfaces and a concrete implementation to create instances depending on configuration via factory classes and ensures a valid config structure. It can also be used to auto discover factories and to create configuration files.

58446.7k34](/packages/sandrokeil-interop-config)[illuminatech/array-factory

Allows DI aware object creation from array definition

2159.6k6](/packages/illuminatech-array-factory)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
