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

ActiveLibrary

cheerios/cheerios-container
===========================

v1.0.0(5mo ago)00MITPHPPHP &gt;=8.4

Since Jan 16Pushed 5mo agoCompare

[ Source](https://github.com/cheerios4316/cheerios-container)[ Packagist](https://packagist.org/packages/cheerios/cheerios-container)[ RSS](/packages/cheerios-cheerios-container/feed)WikiDiscussions main Synced today

READMEChangelog (1)Dependencies (2)Versions (2)Used By (0)

cheerios-container
==================

[](#cheerios-container)

This is a minimal and configurable implementation of a PHP dependency injection container.

Usage
-----

[](#usage)

#### Creating an instance of a class

[](#creating-an-instance-of-a-class)

Calling -&gt;get() or invoking the container will yield an instance of the provided class name.

```
$container = Container::getInstance();

$instance = $container->get(SomeClass::class);
$otherInstance = $container(SomeClass::class); // __invoke() is a short-hand for get()
```

#### Setting default arguments and passing arguments to the Container

[](#setting-default-arguments-and-passing-arguments-to-the-container)

Default arguments can be set for classes that have primitive arguments in their constructors. Additionally, arguments can be passed to -&gt;get() or \_\_invoke() and they will override any conflicting pre-registered value. Trying to create an instance of a class with a primitive argument without providing a value will throw.

```
$container = Container::getInstance()
    ->registerArgs(SomeClass::class, [
        "argumentOne" => "hello",
        "argumentTwo" => "overwrite me!",
    ]);

$instance = $container(
    class: SomeClass::class,
    args: ["argumentTwo" => "world"]
);
```

#### Setting strategies

[](#setting-strategies)

Strategies skip the Container's resolver entirely, as well as registered interfaces and arguments.

```
$container->registerStrategy(SpecialClass::class, function() {
    return specialFunctionThatReturnsASpecialClassInstance();
});

$specialInstance = $container(SpecialClass::class);
```

#### Registering a default for an interface

[](#registering-a-default-for-an-interface)

The provided class name is instantiated when the Container is called on its interface.

```
$container->registerInterface(SomeInterface::class, SomeClass::class);

$instance = $container(SomeInterface::class);
```

###  Health Score

34

—

LowBetter than 75% of packages

Maintenance70

Regular maintenance activity

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity52

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

168d ago

### Community

Maintainers

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

---

Top Contributors

[![cheerios4316](https://avatars.githubusercontent.com/u/138498145?v=4)](https://github.com/cheerios4316 "cheerios4316 (2 commits)")

###  Code Quality

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

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

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

PHPackages © 2026

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