PHPackages                             niletphp/dependency-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. niletphp/dependency-container

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

niletphp/dependency-container
=============================

The NiletPHP dependency injection container.

v1.0.0(8y ago)11512MITPHPPHP &gt;=7.0

Since Apr 21Pushed 8y ago2 watchersCompare

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

READMEChangelogDependencies (1)Versions (2)Used By (2)

PHP dependency injection container
==================================

[](#php-dependency-injection-container)

Dependency container which provides an easy way for managing dependencies in your PHP projects.

### Requirements

[](#requirements)

`PHP >= 7.0`

### Install

[](#install)

Composer

```
{
    "require": {
        "niletphp/dependency-container": ">=v1.0"
    }
}
```

### Examples

[](#examples)

```
$dc = new Nilet\Components\Container\DependencyContainer();
```

Resolve dependencies for a given concrete and return a new instance of it

```
$dc->create("Nilet\Foo");
```

Bind a concrete to interface. Resolving such binding will always return new concrete instance

```
$dc->bind("Nilet\FooInterface", "Nilet\Foo");
$dc->bind("Nilet\FooInterface", function ($dc) {
    return new Nilet\Foo();
});
$dc->create("Nilet\FooInterface");
```

Share a concrete (singleton).

```
$dc->share("Nilet\Foo");
$dc->share("Nilet\Foo", function ($dc) {
    return new Nilet\Foo();
});
```

Binding a concrete (singleton) to an Interface

```
$dc->bindShared("Nilet\FooInterface", "Nilet\Foo");
$dc->bindShared("Nilet\FooInterface", function ($dc) {
    return new Nilet\Foo();
});
```

Register a concrete instance (singleton).

```
$foo = new Nilet\Foo();
$dc->instance("Nilet\Foo", $foo);
```

Retrieve a concrete.

```
$dc->get("Nilet\Foo");

$dc->bindShared("Nilet\FooInterface", "Nilet\Foo");
$dc->get("Nilet\FooInterface");
```

Determine if a given concrete (singleton) has been resolved.

```
$dc->bindShared("Nilet\FooInterface", "Nilet\Foo");
$dc->get("Nilet\FooInterface");
if ($dc->isResolved("Nilet\FooInterface")) { // evaluates to true
    // do something
} else {
    // do something else
}
```

Determine if a given concrete is shared.

```
$dc->share("Nilet\Foo");
if ($dc->isShared("Nilet\Foo")) { // evaluates to true
    // do something
} else {
    // do something else
}
```

Determine if a given interface is bound.

```
$dc->bind("Nilet\FooInterface", "Nilet\Foo");
if ($dc->isBound("Nilet\FooInterface")) { //evaluates to true
    // do something
} else {
    // do something else
}
```

Determine if a given interface is bound/shared.

```
$dc->bindShared("Nilet\FooInterface", "Nilet\Foo");
if ($dc->isBoundShared("Nilet\FooInterface")) { //evaluates to true
    // do something
} else {
    // do something else
}
```

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

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

Unknown

Total

1

Last Release

2946d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/6e014acd2f0c831bd8b1a91b4a10774f71122cb0b32aadfc09cc996fa7693131?d=identicon)[tsvetelin](/maintainers/tsvetelin)

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

PHPackages © 2026

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