PHPackages                             appzcoder/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. [PSR &amp; Standards](/categories/psr-standards)
4. /
5. appzcoder/container

ActiveLibrary[PSR &amp; Standards](/categories/psr-standards)

appzcoder/container
===================

Dependency Injection Container

v1.0(10y ago)8353MITPHPPHP &gt;=5.4.0

Since Oct 19Pushed 8y ago1 watchersCompare

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

READMEChangelog (1)DependenciesVersions (3)Used By (0)

DI Container
============

[](#di-container)

> Dependency Injection Container

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

[](#installation)

1. Run

    ```
    composer require appzcoder/container:"dev-master"

    ```
2. Add bellow lines to your script

    ```
    require 'vendor/autoload.php';
    ```

Usage
-----

[](#usage)

```
class Foo // Has dependencies
{
    protected $bar;
    protected $fooBar;
    protected $name;

    public function __construct(Bar $bar, $name='Sohel Amin', $param2=null) // Dependency Injected
    {
        $this->bar = $bar;
        $this->name = $name;
    }

    public function setterMethod(FooBar $fooBar) // Dependency Injected on method
    {
        return $this->fooBar = $fooBar;
    }
}

class Bar { } // No dependencies

class FooBar { } // No dependencies

// Instantiate the container
$container = new Appzcoder\Container\Container();

// Registering class with dependencies
$container->set('Foo');

// Registering class with another name
$container->set('foo', 'Bar');

// Binding a closure object with a name
$container->setInstance('FooBar', function () {
    return new FooBar();
});

// Registering class with parameters
$container->set('Foo', 'Foo', ['param 1', 'param 2']);

// Binding an instance with a name
$instance = new FooBar();
$container->setInstance('FooBar', $instance);

// Binding an instance/object with container's array
$container['FooBar'] = new FooBar();

// Calling a setter method with dependencies
$container->set('Foo', 'Foo', ['param 1', 'param 2']);
$instance = $container->get('Foo');
$container->call([$instance, 'setterMethod'], ['param 1', 'param 2']);

// Accessing container or getting instances
$instance1 = $container->get('Foo');
$instance2 = $container['Foo']; // For this should have registered or bounded "Foo"
```

Author
------

[](#author)

[Sohel Amin](http://www.sohelamin.com)

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 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

Unknown

Total

1

Last Release

3704d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/beed541009d742df2fff23fc2fc82af84b0decfa90439ba512c4d98b3d24c118?d=identicon)[appzcoder](/maintainers/appzcoder)

---

Top Contributors

[![sohelamin](https://avatars.githubusercontent.com/u/1708683?v=4)](https://github.com/sohelamin "sohelamin (8 commits)")

---

Tags

containerdi-containerpsr-11containerdi container

### Embed Badge

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

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

###  Alternatives

[psr/container

Common Container Interface (PHP FIG PSR-11)

10.0k1.0B3.7k](/packages/psr-container)[pimple/pimple

Pimple, a simple Dependency Injection Container

2.7k130.5M1.4k](/packages/pimple-pimple)[php-di/php-di

The dependency injection container for humans

2.8k48.9M991](/packages/php-di-php-di)[league/container

A fast and intuitive dependency injection container.

86387.8M342](/packages/league-container)[aura/di

A serializable dependency injection container with constructor and setter injection, interface and trait awareness, configuration inheritance, and much more.

356968.3k58](/packages/aura-di)[dvdoug/boxpacker

An implementation of the 3D (actually 4D) bin packing/knapsack problem (aka creating parcels by putting items into boxes)

6522.7M18](/packages/dvdoug-boxpacker)

PHPackages © 2026

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