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

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

lava/container
==============

A fast and intuitive dependency injection container.

v0.91(6y ago)04Apache-2.0PHPCI failing

Since Mar 30Pushed 6y ago1 watchersCompare

[ Source](https://github.com/sir-volcano/Container)[ Packagist](https://packagist.org/packages/lava/container)[ RSS](/packages/lava-container/feed)WikiDiscussions master Synced 6d ago

READMEChangelogDependencies (2)Versions (3)Used By (0)

Lava/Container
==============

[](#lavacontainer)

A fast and intuitive dependency injection container.

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

[](#installation)

```
    composer require lava/container
```

Usage
-----

[](#usage)

创建一个容器实例

```
    require __DIR__."/vendor/autoload.php";
    $container = new \Lava\Container\Container();
```

快速上手

```
    class B{
        protected $a;
        function __construct(A $a)
        {
            $this->a = $a;
        }
    }
    class A{
    }

    // 绑定类实例
    $container->bind("a",new A);
    // 传类名 他会自动帮你实例化A类
    $container->bind("b","B");
    // 使用闭包动态构建A类
    $container->bind('a',function($container){
        return new A;
    });
    //绑定自身
    $container->bind("A");

    //绑定一个共享实例
    $container->singleton("A",function(){
        return new A;
    });

    //绑定会返回一个实例构建器 你可以通过他来写别名或者覆盖旧的构建器
    $container->bind("A")->setAlias("b")->setBuilder(function(){});

```

License
-------

[](#license)

Apache2

###  Health Score

21

—

LowBetter than 18% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity3

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity47

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

2240d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/3183640?v=4)[Borja Gracia](/maintainers/volcanos)[@Volcanos](https://github.com/Volcanos)

---

Top Contributors

[![sir-volcano](https://avatars.githubusercontent.com/u/23112914?v=4)](https://github.com/sir-volcano "sir-volcano (8 commits)")

---

Tags

containerserviceproviderlavaVolcano

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[league/container

A fast and intuitive dependency injection container.

86387.8M343](/packages/league-container)[pimple/pimple

Pimple, a simple Dependency Injection Container

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

PHPackages © 2026

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