PHPackages                             goez/di - 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. goez/di

AbandonedArchivedLibrary[Framework](/categories/framework)

goez/di
=======

Goez Dependency Injection Container

2.0.0(3y ago)567.9k↓80.6%MITPHPPHP &gt;= 8.0

Since Dec 7Pushed 3y agoCompare

[ Source](https://github.com/goez-tools/di)[ Packagist](https://packagist.org/packages/goez/di)[ RSS](/packages/goez-di/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (3)Versions (14)Used By (0)

Goez Dependency Injection Container
===================================

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

[![Build Status](https://camo.githubusercontent.com/da1903cd35d2afb0b0016a65c065c054c7baa3e93dea49b64348579c1eaffd45/68747470733a2f2f7472617669732d63692e6f72672f676f657a2d746f6f6c732f64692e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/goez-tools/di)

A simple dependency injection container which was inspired by Laravel Service Container.

Features
--------

[](#features)

- Nested dependency injection.
- Interface binding.

TODO
----

[](#todo)

- Method injection

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

[](#installation)

```
$ composer require goez/di
```

Usage
-----

[](#usage)

### Initialize

[](#initialize)

```
use Goez\Di\Container;
$container = Container::createInstance();
```

### `make($name[, $arguments])`

[](#makename-arguments)

Make an instance:

```
class App
{
    private $appName;

    public function __construct($appName = 'ThisApp')
    {
        $this->appName = $appName;
    }

    public function getAppName()
    {
        return $this->appName;
    }
}

$app = $container->make(App::class);
echo $app->getAppName(); // ThisApp

$app = $container->make(App::class, ['MyApp']);
echo $app->getAppName(); // MyApp
```

Inject object by type-hint:

```
class App
{
    private $auth;
    private $appName;

    public function __construct(Auth $auth, $appName = 'ThisApp')
    {
        $this->auth = $auth;
        $this->appName = $appName;
    }
}

class Auth {}

$app = $container->make(App::class);
```

Nested dependency injection:

```
class App
{
    private $auth;
    private $appName;

    public function __construct(Auth $auth, $appName = 'ThisApp')
    {
        $this->auth = $auth;
        $this->appName = $appName;
    }
}

class Auth
{
    private $db;

    public function __construct(Db $db)
    {
        $this->db = $db;
    }
}

$app = $container->make(App::class);
```

### `bind($name, $className|$closure)`

[](#bindname-classnameclosure)

Binding by key:

```
$container->bind('db', function ($container) {
    return new Db();
});
$db = $container->make('db');
```

Binding by interface:

```
interface DbInterface {}

class Db implements DbInterface {}

$container->bind(DbInterface::class, Db::class);
$db = $container->make(DbInterface::class);
```

### `instance($name, $instance)`

[](#instancename-instance)

Bind an existed instance.

```
interface DbInterface {}

class Db implements DbInterface {}

$container->instance(DbInterface::class, new Db());
$db1 = $container->make(DbInterface::class);

$container->instance(DbInterface::class, new Db());
$db2 = $container->make(DbInterface::class);

assert($db1 !== $db2); // true
```

### `singleton($name, $instance|$closure)`

[](#singletonname-instanceclosure)

Create singleton instance by closure.

```
interface DbInterface {}

class Db implements DbInterface {}

$container->singleton(DbInterface::class, function (Container $c) {
    return $c->make(Db::class);
    // Or
    return new Db();
});
$db1 = $container->make(DbInterface::class);
$db2 = $container->make(DbInterface::class);

assert($db1 === $db2);
```

Create singleton instance by an existed instance.

```
interface DbInterface {}

class Db implements DbInterface {}

$container->singleton(DbInterface::class, new Db());
$db1 = $container->make(DbInterface::class);
$db2 = $container->make(DbInterface::class);

assert($db1 === $db2);
```

License
-------

[](#license)

MIT

###  Health Score

38

—

LowBetter than 85% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity33

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity75

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

Recently: every ~370 days

Total

13

Last Release

1430d ago

Major Versions

1.1.2 → 2.0.02022-06-10

PHP version history (2 changes)1.0.0PHP &gt;= 5.6

2.0.0PHP &gt;= 8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/000012ed8f10873694d29e2f60b7b71171c088d6fd655a695210dd2fe46172b9?d=identicon)[jaceju](/maintainers/jaceju)

---

Top Contributors

[![jaceju](https://avatars.githubusercontent.com/u/310474?v=4)](https://github.com/jaceju "jaceju (20 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/goez-di/health.svg)

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

###  Alternatives

[laravel/telescope

An elegant debug assistant for the Laravel framework.

5.2k67.8M190](/packages/laravel-telescope)[spiral/roadrunner

RoadRunner: High-performance PHP application server and process manager written in Go and powered with plugins

8.4k12.2M84](/packages/spiral-roadrunner)[nolimits4web/swiper

Most modern mobile touch slider and framework with hardware accelerated transitions

41.8k177.2k1](/packages/nolimits4web-swiper)[laravel/dusk

Laravel Dusk provides simple end-to-end testing and browser automation.

1.9k36.7M255](/packages/laravel-dusk)[laravel/prompts

Add beautiful and user-friendly forms to your command-line applications.

708181.8M591](/packages/laravel-prompts)[cakephp/chronos

A simple API extension for DateTime.

1.4k47.7M121](/packages/cakephp-chronos)

PHPackages © 2026

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