PHPackages                             thecodingmachine/container-discovery - 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. thecodingmachine/container-discovery

ActiveLibrary

thecodingmachine/container-discovery
====================================

Allowing discovery of container objects

14PHP

Since Nov 30Pushed 10y ago4 watchersCompare

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

READMEChangelogDependenciesVersions (1)Used By (0)

Containers discovery for *container-interop*
============================================

[](#containers-discovery-for-container-interop)

This package contains an interface and Puli binding-types to automatically discover containers.

Introduction
------------

[](#introduction)

*container-interop* defines a common interface for Container objects (the `ContainerInterface`). This package proposes a default interface for factories that can generate container objects.

This factory is static and can be automatically detected by Puli using class discovery.

The goal is to allow a composite container to automatically detect and create container instances.

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

[](#installation)

```
composer require thecodingmachine/container-discovery@dev

```

This package adheres to the [SemVer](http://semver.org/) specification and will be fully backward compatible between minor versions.

Containers discovery
--------------------

[](#containers-discovery)

The goal of this package is to enable a package to automatically publish or discover **containers**.

To automatically provide a *container* to your application, we use [Puli's discovery mechanism](http://docs.puli.io/en/latest/discovery/introduction.html).

This package contains a Puli **binding-type** named `container-interop/ContainerFactories`. This binding-type should contain fully qualified class names implementing the `ContainerFactoryInterface` interface.

Providing containers
--------------------

[](#providing-containers)

To provide a container, write a `ContainerFactory` that will return an instance of your container implementing `ContainerInterface`.

For instance (using [Picotainer](https://github.com/mouf/picotainer)):

```
namespace My\Package;

use Interop\Container\Factory\ContainerFactoryInterface;
use Assembly\ArrayDefinitionProvider;

class MyContainerFactory implements ContainerFactoryInterface {
    public static function buildContainer(ContainerInterface $rootContainer, Discovery $discovery) {
        return new Picotainer([
            'logger' => function() {
                new MyLogger();
            },
            $rootContainer
        ]);
    }
}
```

Once your class is written, use Puli to bind it to the list of available containers:

```
$ puli bind "My\\Package\\MyContainerFactory" container-interop/ContainerFactories
```

Note: by convention, you can add a "priority" parameter to the binding. Default priority is 0. Lower priorities are processed first (and therefore, higher priorities are overloading lower priorities).

```
$ puli bind "My\\Package\\MyContainerFactory" container-interop/ContainerFactories --param priority=42
```

Consuming containers
--------------------

[](#consuming-containers)

In your code, you can find all classes of the `container-interop/ContainerFactories` binding-type using:

```
// $discovery is the Puli Discovery object.

$factories = $discovery->findByType('container-interop/ContainerFactories');

// TODO: sample code to sort by priority.
```

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 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.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1847918?v=4)[TheCodingMachine](/maintainers/thecodingmachine)[@thecodingmachine](https://github.com/thecodingmachine)

---

Top Contributors

[![moufmouf](https://avatars.githubusercontent.com/u/1290952?v=4)](https://github.com/moufmouf "moufmouf (1 commits)")

### Embed Badge

![Health badge](/badges/thecodingmachine-container-discovery/health.svg)

```
[![Health](https://phpackages.com/badges/thecodingmachine-container-discovery/health.svg)](https://phpackages.com/packages/thecodingmachine-container-discovery)
```

PHPackages © 2026

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