PHPackages                             jesusslim/kos - 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. jesusslim/kos

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

jesusslim/kos
=============

php container/di

1.0(7y ago)116MITPHPPHP &gt;=5.6.0

Since May 17Pushed 7y ago1 watchersCompare

[ Source](https://github.com/jesusslim/kos)[ Packagist](https://packagist.org/packages/jesusslim/kos)[ RSS](/packages/jesusslim-kos/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependenciesVersions (2)Used By (0)

kos
===

[](#kos)

php concise container/di

usage
-----

[](#usage)

### Install

[](#install)

kos in packagist:

Install:

```
composer require jesusslim/kos

```

### Methods

[](#methods)

#### getInstance()

[](#getinstance)

get instance of kos\\Container.

#### map($key,$class = null)

[](#mapkeyclass--null)

map a class or closure to container.

```
Container::getInstance()->map(Foo::class);
Container::getInstance()->map('foo',Foo::class);
Container::getInstance()->map('bar',function($foo,$bar){return $foo + $bar;});

```

#### mapInstance($key,$instance)

[](#mapinstancekeyinstance)

map an instance to container.

```
Container::getInstance()->mapInstance('foo',new Foo());

```

#### isMapped($key)

[](#ismappedkey)

#### get($key,$params = \[\])

[](#getkeyparams--)

if $key is mapped in container as an instance,return the instance;

if $key is mapped in container as a class,return the an instance of the class;

if $key is mapped in container as a closure,return the result of the closure;

if $key is not mapped in container,reflect $key and return the instance/result;

the values in $params can be used as the params of the constructor of class or the params of closure;

```
class Foo{

    private $bar;

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

    public function getBar(){
        return $this->bar;
    }
}
$container = Container::getInstance();

$container->map(Foo::class);
$container->mapInstance('bar',677);
$container->map('sum',function(Foo $foo,$inc){
    return $foo->getBar()+$inc;
});

$foo = $container->get(Foo::class);
/* @var Foo $foo */
echo $foo->getBar();
//result is 677

$foo = $container->get(Foo::class,['bar' => 688]);
echo $foo->getBar();
//result is 688;

echo $container->get('sum',['inc' => 100]);
//result is 777

```

#### invoke(Closure $closure,$params = \[\])

[](#invokeclosure-closureparams--)

invoke a closure , the params of the closure will be filled by the container.

```
echo $container->invoke(function(Foo $foo,$inc){
    return $foo->getBar()+$inc;
},['inc' => 100]);
//result is 777

```

#### invokeClass($class,$method,$params = \[\])

[](#invokeclassclassmethodparams--)

invoke a class-&gt;method , the params of the closure will be filled by the container.

```
echo $container->invokeClass(Foo::class,'getBar',[]);
//result is 677

```

others
------

[](#others)

kos is a concise container/DI lib for simple use.

and [pinject](https://github.com/jesusslim/pinject) is a lib for the complex use,like caching instances,ArrayAccess implements and chaining operations/workflow with container.

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity58

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

2919d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/8c7f383d1fbc7d01247ec7740bc2fe00036335c9227dab341b1fccdd10cfe0f3?d=identicon)[jesusslim](/maintainers/jesusslim)

---

Top Contributors

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

---

Tags

containerdi

### Embed Badge

![Health badge](/badges/jesusslim-kos/health.svg)

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

###  Alternatives

[php-di/php-di

The dependency injection container for humans

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

A fast and intuitive dependency injection container.

86387.8M343](/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)[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)[slince/di

A flexible dependency injection container

20260.4k6](/packages/slince-di)

PHPackages © 2026

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