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

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

ultra-lite/container
====================

7.0.2(5y ago)2119.1k↓33.3%[1 issues](https://github.com/ultra-lite/container/issues)1MITPHPPHP ^7.4 || ^8.0

Since Dec 15Pushed 5y ago3 watchersCompare

[ Source](https://github.com/ultra-lite/container)[ Packagist](https://packagist.org/packages/ultra-lite/container)[ RSS](/packages/ultra-lite-container/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (4)Versions (17)Used By (1)

[![Build Status](https://camo.githubusercontent.com/b4c2705ddd695c0022b2d26b4c35c86d5050658e4cd798f67917341d95eb76bc/68747470733a2f2f7472617669732d63692e6f72672f756c7472612d6c6974652f636f6e7461696e65722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/ultra-lite/container)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/68fbdaec53798f046e9d8e39f437947bd76335d6ab3b2de1c1e1083dd7c26bad/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f756c7472612d6c6974652f636f6e7461696e65722f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/ultra-lite/container/?branch=master)[![Latest Stable Version](https://camo.githubusercontent.com/51892bc0cc3b34ddd3fac56c2058f169354bd4f039973d8623f8b6b4a0cd9885/68747470733a2f2f706f7365722e707567782e6f72672f756c7472612d6c6974652f636f6e7461696e65722f762f737461626c65)](https://packagist.org/packages/ultra-lite/container)[![MIT Licence](https://camo.githubusercontent.com/fabb40ab22588a0746bb0916ed92739171bde7fb31f281c627aa588bcba62cc2/68747470733a2f2f6261646765732e66726170736f66742e636f6d2f6f732f6d69742f6d69742e7376673f763d313033)](https://opensource.org/licenses/mit-license.php)

[![logo](https://avatars1.githubusercontent.com/u/16309098?v=3&s=100)](https://avatars1.githubusercontent.com/u/16309098?v=3&s=100) Ultra-Lite Container
========================================================================================================================================================

[](#-ultra-lite-container)

An ultra-lightweight DI container. The Ultra-Lite container is PSR-11 compliant. (Previous versions supported container-interop instead.)

Use anonymous functions as factories to specify your services.

This container also supports the Delegate Lookup pattern, and comes with a basic composite container.

Usage
-----

[](#usage)

### Setting services individually

[](#setting-services-individually)

```
$container->set(
    'service-id',
    function (\Psr\Container\ContainerInterface $container) {
        return new \stdClass();
    }
);
```

### Setting services from a config file

[](#setting-services-from-a-config-file)

Add factory closures to the container inline, or using a config file as below.

Example config file:

```
return [
    'service-id' =>
        function (\Psr\Container\ContainerInterface $container) {
            return new \stdClass();
        },
];
```

Using config file:

```
$container->configureFromFile('/wherever/config/di.php');
```

### Service retrieval

[](#service-retrieval)

Get services out of the container like this:

```
$object = $container->get('service-id');
```

### See if a service exists

[](#see-if-a-service-exists)

Check if something is in the container like this:

```
$thingExists = $container->has('service-id');
```

### Use with the Delegate Lookup pattern

[](#use-with-the-delegate-lookup-pattern)

If you're not using the Delegate Lookup concept from the Container-Interop standard, ignore this bit. If you are, you can do this:

```
$container = new \UltraLite\Container\Container();
$delegateContainer = new \UltraLite\CompositeContainer\CompositeContainer(); // or any delegate container
$compositeContainer->addContainer($container); // will vary for other composite containers
$container->setDelegateContainer($myCompositeContainer);
```

The [Ultra-Lite Composite Container](https://github.com/ultra-lite/composite-container) is an extremely lightweight delegate container you may wish to use.

When the container is asked for a service using `get()`, it will return it. It will pass the Composite Container into the factory closure, so it is from here that any dependencies of your service will be retrieved.

Alternatives
------------

[](#alternatives)

Ultra-Lite Container was originally inspired by [Pimple](https://github.com/silexphp/Pimple), which still makes an excellent DI container in PHP. Container-Interop compliant wrappers are available. Another excellent project, [Picotainer](https://github.com/thecodingmachine/picotainer), is along similar lines, with the principle difference being that the dependencies are defined at the time of instantiation of the container.

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

[](#installation)

```
composer require ultra-lite/container
```

Contributions
-------------

[](#contributions)

Contributions welcome.

You can run the tests with `./vendor/bin/behat -c tests/behat/behat.yml` and `./vendor/bin/phpspec r -c tests/phpspec/phpspec.yml`.

###  Health Score

39

—

LowBetter than 86% of packages

Maintenance19

Infrequent updates — may be unmaintained

Popularity33

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity76

Established project with proven stability

 Bus Factor1

Top contributor holds 93.8% 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 ~151 days

Recently: every ~379 days

Total

14

Last Release

1835d ago

Major Versions

2.1.0 → 3.0.02016-05-19

3.1.0 → 4.0.02017-02-08

4.0.0 → 5.0.02017-02-14

5.0.0 → 6.0.02017-02-15

6.2.0 → 7.0.02021-03-10

PHP version history (5 changes)0.1.0PHP &gt;=5.5.0

1.0.0PHP ^7.0.0

3.0.0PHP ^5.6|^7.0

4.0.0PHP ^7.0

7.0.0PHP ^7.4 || ^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/9dc0c2d8bba727c2b30227f0e9eb327906ae55f4673bb48df1c846365e58d526?d=identicon)[Sam-Burns](/maintainers/Sam-Burns)

---

Top Contributors

[![Sam-Burns](https://avatars.githubusercontent.com/u/6594039?v=4)](https://github.com/Sam-Burns "Sam-Burns (30 commits)")[![morozov](https://avatars.githubusercontent.com/u/59683?v=4)](https://github.com/morozov "morozov (2 commits)")

---

Tags

container-interopdelegate-containersdi-containerphppsr-11

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[symfony/dependency-injection

Allows you to standardize and centralize the way objects are constructed in your application

4.2k431.1M7.5k](/packages/symfony-dependency-injection)[illuminate/contracts

The Illuminate Contracts package.

704122.9M10.1k](/packages/illuminate-contracts)[illuminate/container

The Illuminate Container package.

31278.1M2.0k](/packages/illuminate-container)[ecotone/ecotone

Supporting you in building DDD, CQRS, Event Sourcing applications with ease.

558549.8k17](/packages/ecotone-ecotone)[civicrm/civicrm-core

Open source constituent relationship management for non-profits, NGOs and advocacy organizations.

728272.9k20](/packages/civicrm-civicrm-core)[internal/dload

Downloads binaries.

98142.7k10](/packages/internal-dload)

PHPackages © 2026

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