PHPackages                             stg/ieu\_container - 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. [Framework](/categories/framework)
4. /
5. stg/ieu\_container

ActiveLibrary[Framework](/categories/framework)

stg/ieu\_container
==================

ieUtilities - Dependency container

2.0.1(9y ago)0431MITPHP

Since Jun 9Pushed 9y ago1 watchersCompare

[ Source](https://github.com/inceddy/ieu_container)[ Packagist](https://packagist.org/packages/stg/ieu_container)[ RSS](/packages/stg-ieu-container/feed)WikiDiscussions master Synced today

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

ieu\\Container
==============

[](#ieucontainer)

PHP Dependency Injection Container inspired by the AngularJS injector and Pimple\\Container

Usage
-----

[](#usage)

```
use ieu\Container\Container;

$container = (new Container())
	->value('factor', 2)
	->service('multiplier', ['factor', 'Vendor\\Project\\Multiplier'])
	->factory('double', ['multiplier', function($theMultiplierService){
		return function($number) use ($theMultiplierService) {
			return $multiplierServcie->multiply($number);
		};
	}]);

echo $container['factor']; // 2
echo $container['double'](10); // 20
```

Injection
---------

[](#injection)

Dependencies can be injected into services and factories using a *dependency array* `['dependencyA', 'dependencyB', $callableOrClassname]` where the dependecies will be given to the callable or the class constructor as arguments.

```
function some_function($A) {
	echo "function: $A";
}

class Foo {
	public static function bar($A) {
		echo "static method: $A";
	}

	public function baz($A) {
		echo "method: $A";
	}
}

$object = new Foo;

// Setup container

$container = (new Container)
	// Add some content
	->value('A', 'Some value')
	->value('InnerCallbackObject', $object)
	->value('InnerCallbackClosure', function($A){
		echo "inner: $A";
	})

	// Case 1: Closure
	->factory(['A', function($A) {
			echo "closure $A";
		}])

	// Case 2: Function
	->factory('Function', ['A', 'some_function'])

	// Case 3: Static method
	->factory('Static1',  ['A', [Foo::CLASS, 'bar']])

	// Case 4: Static method variant
	->factory('Static2',  ['A', Foo::CLASS . '::bar'])

	// Case 5: Public method
	->factory('Public',   ['A', [$object, 'baz']])

	// Case 7: Container internal callback object
	->factory('Inner',    ['A', ['InnerCallbackObject', 'baz']])

	// Case 7: Container internal callback closure
	->factory('Inner',    ['A', ['InnerCallbackClosure']])
```

A (slower) way is using the parameter names of the callable or constructor to specify the dependencies. E.g. `function($dependencyA, $dependencyB) {...}` has the same result as `['dependencyA', 'dependencyB', function($depA, $depB) { /*...*/ }]`.

*Note: This does not work with inner callbacks!*

### Constant

[](#constant)

Constants can be defined using the `self ieu\Container\Container::constant(string $name, mixed $value)`-method.

*Note: Constants are available during the provider configation cycle!*

### Values

[](#values)

Values can be defined using the `self ieu\Container\Container::value(string $name, mixed $value)`-method.

```
$container = (new Container)
	->value('A', 'Value');
```

### Factory

[](#factory)

Factorys can be defined using the `self ieu\Container\Container::factory(string $name, mixed $factory`-method.

```
$container = (new Container)
	->value('DependencyA', 'Value')

	// With dependency hint
	->factory('Name', ['DependencyA', function($a) {
		echo $a; // Value
	}])

	// Auto resolve
	->factory('Name', function($DependencyA) {
		echo $DependencyA; // Value
	}]);
```

### Service

[](#service)

Services can be defined using the `self ieu\Container\Container::service(string $name, mixed $service)`-method. The service-method expects a class name or a dependency array with the class name as last element as argument. E.g. `['dependencyA', 'dependencyB', 'Vendor\\Project\\Service']` or just (slower) `'Vendor\\Project\\Service'` where the parameter names of the constructor are used to inject the dependencies.

```
class Foo {
	public function __construct($DependencyA) {
		echo $DependencyA; // Value
	}
}

$container = (new Container)
	->value('DependencyA', 'Value')

	// With dependency hint
	->factory('Name', ['DependencyA', Foo::CLASS])

	// Auto resolve
	->factory('Name', Foo::CLASS);
```

### Decorator

[](#decorator)

You can use the `self ieu\Container\Container::decorator(string $name, mixed $decorator)`-method to overload existing dependencies while receiving the original instance as local dependency. Decorators MUST be a `factory` or a `provider`.

```
$container = (new Container)
	->factory('SomeName', [function(){
		return 'Hello';
	}])
	->decorator('SomeName', ['DecoratedInstance', function($org) {
		return $org . 'World';
	}]);

echo $container['SomeName']; // HelloWorld
```

### Provider

[](#provider)

A provider can be any object having the public property `factory` describing the factory as *dependency array*. A provider can be set using the `self ieu\Container\Container::provider(string $name, object $provider)`-method.

Providers can be accessed during configuration process by using their name with `Provider` suffix as dependency.

```
class PrefixerProvider {
	private $prefix = 'Hello';

	public $factory;

	public function __construct()
	{
		$this->factory = ['Name', [$this, 'factory']];
	}

	public function setPrefix(string $prefix) : void
	{
		$this->prefix = $prefix;
	}

	public function factory(string $name) : string
	{
		return sprtinf('%s %s', $this->prefix, $name);
	}
}

$container = (new Container)
	->factory('Name', [function(){
		return 'Justus';
	}])
	->provider('PrefixedName', new PrefixerProvider))
	->config(['PrefixedNameProvider', function($provider) {
		$provider->setPrefix('Goodbye');
	}]);

echo $container['PrefixedName']; // Goodbye Justus
```

###  Health Score

28

—

LowBetter than 52% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity64

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 ~4 days

Total

2

Last Release

3303d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/60855572496c9ef88a095c897f8cde25b4fdab684fafab0aaba58c50cfa1aaee?d=identicon)[inceddy](/maintainers/inceddy)

---

Top Contributors

[![inceddy](https://avatars.githubusercontent.com/u/11957976?v=4)](https://github.com/inceddy "inceddy (26 commits)")

### Embed Badge

![Health badge](/badges/stg-ieu-container/health.svg)

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

###  Alternatives

[laravel/framework

The Laravel Framework.

34.8k532.1M19.4k](/packages/laravel-framework)[cakephp/cakephp

The CakePHP framework

8.8k19.1M1.7k](/packages/cakephp-cakephp)[shopware/platform

The Shopware e-commerce core

3.4k1.5M3](/packages/shopware-platform)[cakephp/datasource

Provides connection managing and traits for Entities and Queries that can be reused for different datastores

4725.8M15](/packages/cakephp-datasource)[flow-php/flow

PHP ETL - Extract Transform Load - Data processing framework

84735.1k](/packages/flow-php-flow)[cakephp/cache

Easy to use Caching library with support for multiple caching backends

498.6M24](/packages/cakephp-cache)

PHPackages © 2026

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