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

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

lee/simple-container
====================

PHP library that reflect the specific classes

1.0.1(7y ago)1432MITPHPPHP &gt;=7.1.0

Since Feb 26Pushed 7y ago1 watchersCompare

[ Source](https://github.com/peter279k/simple-container)[ Packagist](https://packagist.org/packages/lee/simple-container)[ RSS](/packages/lee-simple-container/feed)WikiDiscussions master Synced 3d ago

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

simple-container
================

[](#simple-container)

[![Build Status](https://camo.githubusercontent.com/d9a4665203c431afd81d034625b88be2cb16092aa1d22e4c2f3736ab5a25cfa6/68747470733a2f2f7472617669732d63692e6f72672f70657465723237396b2f73696d706c652d636f6e7461696e65722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/peter279k/simple-container)[![Coverage Status](https://camo.githubusercontent.com/8db94930e275e8ca2d29079e3f8412e15ac9be72c44249f8f16bd581de56019d/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f70657465723237396b2f73696d706c652d636f6e7461696e65722f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/peter279k/simple-container?branch=master)

Introduction
------------

[](#introduction)

This is about the simple container to help developers to understand how the Reflection works.

Usage
-----

[](#usage)

Firstly, you have to specify a class that you want to inject.

For example, we assume that you want to inject following `Profile` class:

```
class Profile
{
    protected $userName;

    public function __construct($userName = 'lee')
    {
        $this->userName = $userName;
    }

    public function getUserName()
    {
        return $this->userName;
    }
}
```

Then we use the `Container` class to inject this `Profile` class.

```
use Lee\Container\Container;

$container = new Container();
$container->set(Profile::class);
$profile = $container->get(Profile::class);

echo $profile->getUserName(); // lee
```

If you want to inject class that its constructor arguments is without the default value, we should specify them by ourselves.

The sample codes are as follows:

```
class Profile
{
    protected $userName;

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

    public function getUserName()
    {
        return $this->userName;
    }
}
```

Then we use `Container` class to inject this class.

```
use Lee\Container\Container;

$container = new Container();
$container->set(Profile::class);
$profile = $container->get(Profile::class, ['userName' => 'Peter']);

echo $profile->getUserName(); // Peter
```

References
==========

[](#references)

This simple-container is about implementing this [post](https://medium.com/tech-tajawal/dependency-injection-di-container-in-php-a7e5d309ccc6).

However, this post we refer is incorrect on some approaches.

We decide to implement this PHP package to complete the correct container example.

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity56

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

Total

2

Last Release

2635d ago

### Community

Maintainers

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

---

Top Contributors

[![peter279k](https://avatars.githubusercontent.com/u/9021747?v=4)](https://github.com/peter279k "peter279k (7 commits)")

---

Tags

containerdependency-injectionhacktoberfestphp71reflection

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

PHPackages © 2026

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