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

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

chipslays/container
===================

2.0.0(2y ago)013MITPHPPHP ^8.0

Since Dec 1Pushed 2y ago1 watchersCompare

[ Source](https://github.com/chipslays/container)[ Packagist](https://packagist.org/packages/chipslays/container)[ RSS](/packages/chipslays-container/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (3)Dependencies (2)Versions (4)Used By (0)

📦 DI Container
==============

[](#-di-container)

Yet another implementation of dependency injection container with PSR-11 compliant for PHP &gt;8.0.

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

[](#installation)

```
composer require please/container
```

Basic usage
-----------

[](#basic-usage)

This example always returns a new instance of `Mailer`.

```
use Please\Container\Container;
use Please\Container\Support\Getter;

$container = new Container;

$container->bind(Mailer::class, function (Getter $get) {
    return new Mailer::($get('user'), $get('password', 'qwerty')); // qwerty - default value
});

/** @var Mailer */
$mailer = $container->get(Mailer::class, [
  'user' => 'admin',
  // and password `qwerty` (default value)
]);
```

This example always return a same time.

```
use Please\Container\Container;

$container = new Container;

$container->singleton('random', fn () => rand());

echo $container->get('random'); // 1234567890
echo $container->get('random'); // 1234567890
```

Examples
--------

[](#examples)

You can find usage examples [here](/examples).

Documentation
-------------

[](#documentation)

You can bind any abstract aliases.

```
use Please\Container\Container;

$container = new Container;

$container->bind(Foo::class);
$container->get(Foo::class); // ok
$container->get('foo'); // error

// if you pass a class string
// it is also automatically bind as `Foo::class`
$container->bind('foo', Foo::class);
$container->get(Foo::class); // ok
$container->get('foo'); // ok

// array of aliases
$container->bind([Foo::class, 'foo', 'another-foo-alias'], Foo::class);
$container->get(Foo::class); // ok
$container->get('foo'); // ok
$container->get('another-foo-alias'); // ok
```

You can bind any primitive data types.

```
$container->bind('foo', 'bar');
$container->bind('foo', 1337);
$container->bind('foo', 13.37);
$container->bind('foo', true || false);
$container->bind('foo', ['bar', 'baz']);
$container->bind('foo', new stdClass);
$container->bind('foo', fopen('php://stdout', 'r'));

$container->bind('baz', null);
$container->get('baz') // returns `baz`
```

Generates a singleton instance of a class.

> Singleton method always returns same value or instance like typical singleton pattern.

```
$container->singleton('timestamp', fn () => time());

// or use bind class and `shared` parameter
$container->bind('timestamp', fn () => time(), shared: true);
```

Check if the container has a binding or instance for the given abstract.

```
$container->bind('foo', 'bar');
$container->has('foo'); // true
$container->has('baz'); // false
```

Singleton Pattern
-----------------

[](#singleton-pattern)

If you really need to, you can use the container as a singleton.

```
use Please\Container\Container as BaseContainer;
use Please\Container\Support\Traits\Singleton;

class Container extends BaseContainer
{
    use Singleton;
}

...

$container = Container::getInstance();

...
```

You can also check singleton example [here](/examples/singleton.php).

License
-------

[](#license)

Open-sourced software licensed under the [MIT license](https://opensource.org/license/mit/).

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity49

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

Every ~65 days

Total

3

Last Release

768d ago

Major Versions

1.0.1 → 2.0.02024-04-10

PHP version history (2 changes)1.0.0PHP ^8.1

2.0.0PHP ^8.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/19103498?v=4)[chipslays](/maintainers/chipslays)[@chipslays](https://github.com/chipslays)

---

Top Contributors

[![chipslays](https://avatars.githubusercontent.com/u/19103498?v=4)](https://github.com/chipslays "chipslays (12 commits)")

---

Tags

containerdi-containerphp-containerphp-diphp-di-containercontainerphp-diphp-container

### Embed Badge

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

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

###  Alternatives

[pimple/pimple

Pimple, a simple Dependency Injection Container

2.7k130.5M1.4k](/packages/pimple-pimple)[league/container

A fast and intuitive dependency injection container.

86387.8M343](/packages/league-container)[php-di/php-di

The dependency injection container for humans

2.8k48.9M994](/packages/php-di-php-di)[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)[league/tactician-container

Tactician integration for any container implementing PSR-11

7710.1M23](/packages/league-tactician-container)[mrclay/props-dic

Props is a simple DI container that allows retrieving values via custom property and method names

3611.7M3](/packages/mrclay-props-dic)

PHPackages © 2026

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