PHPackages                             phly/phly-expressive-configfactory - 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. [PSR &amp; Standards](/categories/psr-standards)
4. /
5. phly/phly-expressive-configfactory

Abandoned → [phly/phly-configfactory](/?search=phly%2Fphly-configfactory)ArchivedLibrary[PSR &amp; Standards](/categories/psr-standards)

phly/phly-expressive-configfactory
==================================

Factory for pulling nested configuration arrays from the config service

1.1.1(6y ago)2727BSD-3-ClausePHPPHP ^7.1

Since Feb 6Pushed 6y ago1 watchersCompare

[ Source](https://github.com/phly/phly-expressive-configfactory)[ Packagist](https://packagist.org/packages/phly/phly-expressive-configfactory)[ RSS](/packages/phly-phly-expressive-configfactory/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (3)Dependencies (5)Versions (4)Used By (0)

phly-expressive-configfactory
=============================

[](#phly-expressive-configfactory)

> ## Abandoned
>
> [](#abandoned)
>
> This package is abandoned as of 2020-01-14. Users are encouraged to migrate to [Laminas](https://getlaminas.org) and to use [phly/phly-configfactory](https://github.com/phly/phly-configfactory) as a replacement for this package.

[![Build Status](https://camo.githubusercontent.com/d8913c48aefd5d46cc40d4bafc8007ce8bcec278116e622a7c32931e2fd9dd0e/68747470733a2f2f7365637572652e7472617669732d63692e6f72672f70686c792f70686c792d657870726573736976652d636f6e666967666163746f72792e7376673f6272616e63683d6d6173746572)](https://secure.travis-ci.org/phly/phly-expressive-configfactory)[![Coverage Status](https://camo.githubusercontent.com/5fa3f82d1e68f36ffb419b4e1029ec7be1f3acffa655cc9a8ffc8b29d63903d8/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f70686c792f70686c792d657870726573736976652d636f6e666967666163746f72792f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/phly/phly-expressive-configfactory?branch=master)

This library provides a re-usable factory for pulling configuration from nested keys.

Installation
------------

[](#installation)

Run the following to install this library:

```
$ composer require phly/phly-expressive-configfactory
```

Usage
-----

[](#usage)

Assign the factory `Phly\Expressive\ConfigFactory` to services named with the following structure:

```
config-

```

As an example, if you have the following structure:

```
return [
    'cache' => [
        'adapters' => [
            'blog' => [
                'connection' => 'tcp://localhost:6349',
                'username'   => 'www-data',
                'prefix'     => 'blog',
            ],
        ],
    ],
];
```

and you wanted the "blog" adapter configuration, you would assign the dependency as follows:

```
return [
    'dependencies' => [
        'factories' => [
            'config-cache.adapters.blog' => \Phly\Expressive\ConfigFactory,
        ],
    ],
];
```

### Return empty or raise exception

[](#return-empty-or-raise-exception)

By default, if no configuration at the expected key is found, the factory returns an empty array. If you want it to instead raise an exception, you can assign the factory as follows:

```
return [
    'dependencies' => [
        'factories' => [
            'config-cache.adapters.blog' => new \Phly\Expressive\ConfigFactory(false),
        ],
    ],
];
```

> This operation is safe, as `ConfigFactory` implements `__set_state()`, allowing it to be serialized safely with `var_export()`.

The exception will indicate the key hierarchy it was attempting to retrieve.

### Using configuration in factories

[](#using-configuration-in-factories)

In your factories, you will refer to the metaname when retrieving the service. Following our example above:

```
use Psr\Container\ContainerInterface;

class BlogCacheFactory
{
    public function __invoke(ContainerInterface $container)
    {
        return new Cache($container->get('config-cache.adapters.blog'));
    }
}
```

### Abstract Factory

[](#abstract-factory)

> Since 1.1.0

If you are using [zend-servicemanager](https://docs.zendframework.com/zend-servicemanager), you can use the class `Phly\Expressive\ConfigAbstractFactory` as an abstract factory. This allows you to omit adding a factory entry for every configuration segment you want to retrieve. Instead, you can add the following:

```
return [
    'dependencies' => [
        'abstract_factories' => [
            \Phly\Expressive\ConfigAbstractFactory::class,

            // OR

            new \Phly\Expressive\ConfigAbstractFactory(false),
        ],
    ],
];
```

When present, it will handle any services with the prefix `config-`, and operate in the same way as the `ConfigFactory`.

### Caveats

[](#caveats)

You should only specify keys that will return an array. Most containers only allow returning an array or object from factories, and will raise an exception otherwise. For those requiring an object, Expressive generally casts to an `ArrayObject` instance, making this safe.

Support
-------

[](#support)

- [Issues](https://github.com/zendframework/phly-expressive-configfactory/issues/)

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 94.1% 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 ~170 days

Total

3

Last Release

2307d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/25943?v=4)[Matthew Weier O'Phinney](/maintainers/weierophinney)[@weierophinney](https://github.com/weierophinney)

---

Top Contributors

[![weierophinney](https://avatars.githubusercontent.com/u/25943?v=4)](https://github.com/weierophinney "weierophinney (16 commits)")[![mkherlakian](https://avatars.githubusercontent.com/u/1141190?v=4)](https://github.com/mkherlakian "mkherlakian (1 commits)")

---

Tags

expressivephppsr11PSR-11configexpressive

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/phly-phly-expressive-configfactory/health.svg)

```
[![Health](https://phpackages.com/badges/phly-phly-expressive-configfactory/health.svg)](https://phpackages.com/packages/phly-phly-expressive-configfactory)
```

###  Alternatives

[php-di/php-di

The dependency injection container for humans

2.8k48.9M991](/packages/php-di-php-di)[laminas/laminas-servicemanager

Factory-Driven Dependency Injection Container

15955.1M693](/packages/laminas-laminas-servicemanager)[laminas/laminas-di

Automated dependency injection for PSR-11 containers

3618.1M38](/packages/laminas-laminas-di)[elie29/zend-phpdi-config

PSR-11 PHP-DI autowire container configurator for Laminas, Mezzio, ZF2, ZF3 and Zend Expressive applications

20238.6k7](/packages/elie29-zend-phpdi-config)[bnf/phpstan-psr-container

PHPStan dynamic return type extension for PSR-11 ContainerInterface

133.5M53](/packages/bnf-phpstan-psr-container)

PHPackages © 2026

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