PHPackages                             mnapoli/assembly - 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. mnapoli/assembly

AbandonedArchivedLibrary

mnapoli/assembly
================

Implementation of interop container definitions

0.2.0(10y ago)6376↑2900%5[2 issues](https://github.com/mnapoli/assembly/issues)[1 PRs](https://github.com/mnapoli/assembly/pulls)4MITPHPPHP &gt;=5.4

Since Nov 29Pushed 9y ago3 watchersCompare

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

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

Assembly
========

[](#assembly)

*This repository is experimental*

*Assembly* provides an implementation for [definition-interop](https://github.com/container-interop/definition-interop) definitions as well as a compatible container.

[![Build Status](https://camo.githubusercontent.com/435a5c10e0a3c35cfbb5d716e18b642c3a01c929479605c6bd6fd780276de9c9/68747470733a2f2f7472617669732d63692e6f72672f6d6e61706f6c692f617373656d626c792e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/mnapoli/assembly)

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

[](#installation)

```
composer require mnapoli/assembly@dev

```

Usage
-----

[](#usage)

While you can implement `Interop\Container\Definition\DefinitionProviderInterface` and return an array of definition objects built manually, Assembly provides a natural API to create definitions more easily.

To take advantage of this, simply extend `Assembly\ArrayDefinitionProvider` and fill the `getArrayDefinitions` method:

```
class MyModuleDefinitionProvider extend \Assembly\ArrayDefinitionProvider
{
    public function getArrayDefinitions()
    {
        return [
            'logger.destination' => '/var/log/myapp.log',

            'logger' => \Assembly\object('MyLogger')
                ->setConstructorArguments('warning', \Assembly\get('logger.destination'))
                ->addMethodCall('setDebug', true),

            'super_mailer' => \Assembly\factory('MailerFactory', 'create'),

            'mailer' => \Assembly\get('super_mailer'),
        ];
    }
}
```

If you are using PHP 5.6 or above, you can import namespaced functions:

```
use function \Assembly\object;
use function \Assembly\get;

class MyModuleDefinitionProvider extend \Assembly\ArrayDefinitionProvider
{
    public function getArrayDefinitions()
    {
        return [
            'logger' => object(MyLogger::class),
            'logger_alias' => get('logger'),
        ];
    }
}
```

If you do not want to write a new class, you can also instantiate a new provider directly:

```
$provider = new ArrayDefinitionProvider([
    // add definitions here
]);
```

Definition classes
------------------

[](#definition-classes)

If you do not want to use the function helpers, you can also create definition instances directly.

### ParameterDefinition

[](#parameterdefinition)

```
return [
    'db.port' => new ParameterDefinition(3306),
];
```

This definition will define a container entry `"db.port"`. That means `get('db.port')` will return `3306`.

### Reference

[](#reference)

```
return [
    'logger' => new Reference('monolog'),
];
```

This definition will alias the entry "logger" to the entry "monolog". That means that `get('logger')` will return the result of `get('monolog')`.

### ObjectDefinition

[](#objectdefinition)

```
$definition = new ObjectDefinition('PDO');
$definition->addConstructorArgument('mysql:host=localhost;dbname=test');
$definition->addConstructorArgument('user');
$definition->addConstructorArgument('password');
```

The definition above will return the result of `new PDO('mysql:host=localhost;dbname=test', 'user', 'password')`.

References can also be used:

```
$definition = new ObjectDefinition('PDO');
$definition->addConstructorArgument(new Reference('db.connection_string'));
$definition->addConstructorArgument('user');
$definition->addConstructorArgument('password');
```

The definition above will return the result of `new PDO($container->get('db.connection_string'), 'user', 'password')`.

### FactoryCallDefinition

[](#factorycalldefinition)

The definition below will call the `create()` method on the `db.factory` container entry and return its result:

```
$definition = new FactoryCallDefinition(new Reference('db.factory'), 'create');
$definition->setArguments(new Reference('db.connection_string'), 'user', 'password');
```

The definition below will call the static `Acme\DbFactory::create()` method:

```
$definition = new FactoryCallDefinition('Acme\DbFactory', 'create');
```

Container
---------

[](#container)

Assembly ships with a simple container that is compatible with the standard definitions. The goal of this container is to provide a very easy way to get started for those wanting to consume definitions.

Here is how to use it:

```
// List the definition providers to load
$definitionProviders = [
    new Module1DefinitionProvider(),
    new Module2DefinitionProvider(),
];

// Define here container entries for the application
$entries = [
    'abc' => 'def',
    'router' => new Router(...),
];

$container = new Container($entries, $definitionProviders);
```

For simplicity's sake, the container is immutable and its API is very limited. You are encouraged to use any other compatible container if you are left unsatisfied.

### Definition resolver

[](#definition-resolver)

The "definition resolver" of the container is written in a separate `Assembly\Container\DefinitionResolver` class. This class is meant to be reused in any other container that wishes to support *definition-interop*. Using it is very simple:

```
$resolver = new \Assembly\Container\DefinitionResolver($container);
$value = $resolver->resolve($definition);
```

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance13

Infrequent updates — may be unmaintained

Popularity20

Limited adoption so far

Community22

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 62.5% 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 ~2 days

Total

3

Last Release

3815d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/329a6111724074f5388e95dd41a03ccf3c43f4bfe1ecf27c94c9efc6f7823228?d=identicon)[mnapoli](/maintainers/mnapoli)

---

Top Contributors

[![mnapoli](https://avatars.githubusercontent.com/u/720328?v=4)](https://github.com/mnapoli "mnapoli (40 commits)")[![Anahkiasen](https://avatars.githubusercontent.com/u/1321596?v=4)](https://github.com/Anahkiasen "Anahkiasen (12 commits)")[![Guillaume-Rossignol](https://avatars.githubusercontent.com/u/7794372?v=4)](https://github.com/Guillaume-Rossignol "Guillaume-Rossignol (5 commits)")[![moufmouf](https://avatars.githubusercontent.com/u/1290952?v=4)](https://github.com/moufmouf "moufmouf (5 commits)")[![XedinUnknown](https://avatars.githubusercontent.com/u/1428973?v=4)](https://github.com/XedinUnknown "XedinUnknown (2 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/mnapoli-assembly/health.svg)

```
[![Health](https://phpackages.com/badges/mnapoli-assembly/health.svg)](https://phpackages.com/packages/mnapoli-assembly)
```

###  Alternatives

[laminas/laminas-mvc

Laminas's event-driven MVC layer, including MVC Applications, Controllers, and Plugins

17224.4M365](/packages/laminas-laminas-mvc)[laminas/laminas-mvc-i18n

Integration between laminas-mvc and laminas-i18n

144.5M44](/packages/laminas-laminas-mvc-i18n)[chadicus/slim-oauth2-middleware

OAuth2 middleware for use within a Slim Framework API

48411.9k1](/packages/chadicus-slim-oauth2-middleware)[mouf/pimple-interop

This project is a very simple extension to the Pimple microframework. It adds to Pimple compatibility with the container-interop APIs.

102.4M2](/packages/mouf-pimple-interop)[enlitepro/enlite-monolog

Monolog integration to Laminas

18641.6k](/packages/enlitepro-enlite-monolog)[maglnet/magl-markdown

Provides a ZF2 View Helper to render markdown syntax. It uses third-party libraries for the rendering and you can switch between different renderers.

22178.2k4](/packages/maglnet-magl-markdown)

PHPackages © 2026

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