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

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

quanta/container
================

Minimalist dependency injection container implementing Psr-11

1.0(3y ago)2228MITPHP

Since Oct 12Pushed 3y ago1 watchersCompare

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

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

Quanta Psr-11 container
=======================

[](#quanta-psr-11-container)

This package provides a minimalist dependency injection container implementing [Psr-11](https://www.php-fig.org/psr/psr-11/).

The goal is to implement a container working out of the box with minimal configuration, implementing interface aliasing and a basic autowiring mechanism.

- [Getting started](#getting-started)
- [Basic usage](#basic-usage)
- [Interface aliasing](#interface-aliasing)
- [Autowiring](#autowiring)

Getting started
---------------

[](#getting-started)

**Require** php &gt;= 7.4

**Installation** `composer require quanta/container`

**Run tests** `php ./vendor/bin/phpunit`

**Testing a specific php version using docker:**

- `docker build . --build-arg PHP_VERSION=7.4 --tag quanta/container/tests:7.4`
- `docker run --rm quanta/container/tests:7.4`

Basic usage
-----------

[](#basic-usage)

- container entries are defined using any iterable as long as keys can be casted as strings
- any non callable value is returned as is like an associative array
- any callable value is treated as a factory building the associated value (the results are cached so the callable is run only once and the same value is returned on every `->get()` call)

```
