PHPackages                             amber/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. [Utility &amp; Helpers](/categories/utility)
4. /
5. amber/container

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

amber/container
===============

Simple PHP DI Container.

v1.2.6(5y ago)21.4kGPL-3.0-or-laterPHPPHP &gt;=7.2.0CI failing

Since Mar 22Pushed 5y ago1 watchersCompare

[ Source](https://github.com/systemson/container)[ Packagist](https://packagist.org/packages/amber/container)[ RSS](/packages/amber-container/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (6)Dependencies (6)Versions (22)Used By (0)

[![GitHub last commit](https://camo.githubusercontent.com/861e8b6c562e053e553cd442e2e0ece619254aaafb95aae733d9dd4b78be79f2/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6173742d636f6d6d69742f73797374656d736f6e2f636f6e7461696e65722e737667)](https://camo.githubusercontent.com/861e8b6c562e053e553cd442e2e0ece619254aaafb95aae733d9dd4b78be79f2/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6173742d636f6d6d69742f73797374656d736f6e2f636f6e7461696e65722e737667)[![Latest Stable Version](https://camo.githubusercontent.com/023e2e7415df29f6ea981512fe1357015750c2124bb42baa5861e2710a9227fb/68747470733a2f2f706f7365722e707567782e6f72672f616d6265722f636f6e7461696e65722f762f737461626c652e706e67)](https://packagist.org/packages/amber/container)[![Latest Beta Version](https://camo.githubusercontent.com/1d143a1438a077fc47aeb56a7fb0e5373b986448fb775c6e0bc581c732b30c4c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f767072652f616d6265722f636f6e7461696e65722e737667)](https://packagist.org/packages/amber/container)[![PHP from Packagist](https://camo.githubusercontent.com/b263653c26dfd1005a3aa734441bb0fb5180579c508a0174a341d83eccb71249/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f616d6265722f636f6e7461696e65722e737667)](https://camo.githubusercontent.com/b263653c26dfd1005a3aa734441bb0fb5180579c508a0174a341d83eccb71249/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f616d6265722f636f6e7461696e65722e737667)[![Build Status](https://camo.githubusercontent.com/4de8ed382617dc3c9f529a47d30e89334fcc0e35c1464eec1bda0577ff290d45/68747470733a2f2f7472617669732d63692e6f72672f73797374656d736f6e2f636f6e7461696e65722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/systemson/container)[![Coverage Status](https://camo.githubusercontent.com/d383b3efc600bd9e32280f13943c09c52764d62753ce470b702f29dff2cf7470/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f73797374656d736f6e2f636f6e7461696e65722f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/systemson/container?branch=master)[![Total Downloads](https://camo.githubusercontent.com/a0a61a65e3b4a478309a167e47c5ae274f1ceb0a4b960b00eb5ddac0dd5b5b51/68747470733a2f2f706f7365722e707567782e6f72672f616d6265722f636f6e7461696e65722f646f776e6c6f6164732e706e67)](https://packagist.org/packages/amber/container)[![GitHub](https://camo.githubusercontent.com/0bf30399d082b9119b9d2bac982273e9c4f044ab77bfb4530884d4cc727c2cf6/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f73797374656d736f6e2f636f6e7461696e65722e737667)](https://camo.githubusercontent.com/0bf30399d082b9119b9d2bac982273e9c4f044ab77bfb4530884d4cc727c2cf6/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f73797374656d736f6e2f636f6e7461696e65722e737667)

Container
=========

[](#container)

Simple PHP DI Container.

Instalation
-----------

[](#instalation)

```
composer require amber/container

```

API (Draft)
-----------

[](#api-draft)

### Basic Usage (PSR-11 compliance)

[](#basic-usage-psr-11-compliance)

```
use Amber\Container\Container;

$container = new Container();
```

### bind()

[](#bind)

#### Binds an item to the Container's map by a unique key.

[](#binds-an-item-to-the-containers-map-by-a-unique-key)

bind(string $key, mixed $value) : boolean

**param** string $key *The unique item's key.*

**param** mixed $value *The value of the item.*

**return** bool *True on success. False if key already exists.*

Bind an Service to the container by a unique key.

```
$container->bind($key, $value);
```

Or bind a class like this.

```
$container->bind($class);
```

### get()

[](#get)

#### Gets an item from the Container's map by its unique key

[](#gets-an-item-from-the-containers-map-by-its-unique-key)

get(string $key): mixed

**param** string $key \*The unique item's key.

**return** mixed *The value of the item.*

```
$container->get($key);
```

### has()

[](#has)

#### Checks for the existance of an item on the Container's map by its unique key.

[](#checks-for-the-existance-of-an-item-on-the-containers-map-by-its-unique-key)

has(string $key): bool **param** string $key \*The unique item's key. **return** bool

```
$container->has($key);
```

### unbind()

[](#unbind)

#### Unbinds an item from the Container's map by its unique key.

[](#unbinds-an-item-from-the-containers-map-by-its-unique-key)

unbind(string $key): bool

**param** string $key \*The unique item's key.

**return** bool *true on success, false on failure.*

```
$container->unbind($key);
```

Multiple actions
----------------

[](#multiple-actions)

### bindMultiple()

[](#bindmultiple)

```
$container->bindMultiple([$key => $value]);
```

### getMultiple()

[](#getmultiple)

```
$container->getMultiple($keys);
```

### unbindMultiple()

[](#unbindmultiple)

```
$container->unbindMultiple($keys);
```

Advanced Usage
--------------

[](#advanced-usage)

### make()

[](#make)

#### Binds and Gets a Service from the Container's map by its unique key.

[](#binds-and-gets-a-service-from-the-containers-map-by-its-unique-key)

make(string $class): mixed

**param** string $class *The item's class.*

**return** mixed *The value of the item.*

```
$container->make($class);
```

### register()

[](#register)

#### Binds an class to the Container and return the ServiceClass.

[](#binds-an-class-to-the-container-and-return-the-serviceclass)

register(string $class, string $alias = null): ServiceClass

**param** string $class *The item's class.*

**param** string $alias *The item's alias.*

**return** ServiceClass

```
$container->register($class);
```

### singleton()

[](#singleton)

#### Binds an class to the Container as singleton and return theServiceClassservice.

[](#binds-an-class-to-the-container-as-singleton-and-return-theserviceclassservice)

singleton(string $class, string $alias = null): ServiceClass

**param** string $class *The item's class.*

**param** string $alias *The item's alias.*

**return** ServiceClass

```
$container->singleton($class);
```

### getClosureFor()

[](#getclosurefor)

#### Gets a closure for a method of the provided class.

[](#gets-a-closure-for-a-method-of-the-provided-class)

getClosureFor(string $class, string $method, array $binds = \[\]): Closure

**param** string $class *The class to instantiate.*

**param** string $method *The class method to call.*

**param** array $binds *The arguments for the service.*

**return** Closure

```
$container->getClosureFor($class, $method);
```

**More coming soon...**

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 94.7% 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 ~22 days

Recently: every ~32 days

Total

21

Last Release

2171d ago

Major Versions

v1.2.0-beta → v2.0.0-beta2019-11-06

PHP version history (3 changes)v1.0.0-betaPHP &gt;=7.1.0

v1.0.1PHP &gt;=7.2.0

v2.0.0-betaPHP &gt;=7.4

### Community

Maintainers

![](https://www.gravatar.com/avatar/1912ffd7709c7c3d7498921fd3080e23589e5cee9fb84a4d3831126739ac85b5?d=identicon)[systemson](/maintainers/systemson)

---

Top Contributors

[![systemson](https://avatars.githubusercontent.com/u/32528630?v=4)](https://github.com/systemson "systemson (178 commits)")[![devilu](https://avatars.githubusercontent.com/u/25694532?v=4)](https://github.com/devilu "devilu (7 commits)")[![milanegrin](https://avatars.githubusercontent.com/u/82895394?v=4)](https://github.com/milanegrin "milanegrin (3 commits)")

---

Tags

dependency-injection-containerioc-containerphppsr-11

### Embed Badge

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

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

###  Alternatives

[illuminate/container

The Illuminate Container package.

31278.1M2.0k](/packages/illuminate-container)[symfony/type-info

Extracts PHP types information.

19751.9M114](/packages/symfony-type-info)[ecotone/ecotone

Supporting you in building DDD, CQRS, Event Sourcing applications with ease.

558549.8k17](/packages/ecotone-ecotone)[civicrm/civicrm-core

Open source constituent relationship management for non-profits, NGOs and advocacy organizations.

728272.9k20](/packages/civicrm-civicrm-core)[internal/dload

Downloads binaries.

98142.7k10](/packages/internal-dload)[symfony/object-mapper

Provides a way to map an object to another object

34885.7k18](/packages/symfony-object-mapper)

PHPackages © 2026

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