PHPackages                             corpus/di - 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. corpus/di

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

corpus/di
=========

Simple Yet Powerful PSR-11 Complaint Di Container

v2.4.0(2y ago)43.5k↓33.3%MITPHPPHP &gt;=7.4CI passing

Since May 12Pushed 5mo ago1 watchersCompare

[ Source](https://github.com/CorpusPHP/Di)[ Packagist](https://packagist.org/packages/corpus/di)[ RSS](/packages/corpus-di/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (8)Dependencies (5)Versions (12)Used By (0)

Corpus Di
=========

[](#corpus-di)

[![Latest Stable Version](https://camo.githubusercontent.com/8d8b79d3a4675b09215d300c75f218f398eecff53f964a5efc816d915d9501e4/68747470733a2f2f706f7365722e707567782e6f72672f636f727075732f64692f76657273696f6e)](https://packagist.org/packages/corpus/di)[![License](https://camo.githubusercontent.com/f9ede6756aff4fc71f2af9b128ea784719ae76cdfb8ce63226f247e3d7cfcc65/68747470733a2f2f706f7365722e707567782e6f72672f636f727075732f64692f6c6963656e7365)](https://packagist.org/packages/corpus/di)[![ci.yml](https://github.com/CorpusPHP/Di/actions/workflows/ci.yml/badge.svg?)](https://github.com/CorpusPHP/Di/actions/workflows/ci.yml)[![Coverage Status](https://camo.githubusercontent.com/9b9c5e7565164da9340f93a3aaea121611f0efc5b9e11f62fe867ce3f74c05ec/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f436f727075735048502f44692f62616467652e737667)](https://coveralls.io/github/CorpusPHP/Di)

A Simple PSR-11 Complaint Di Container

Requirements
------------

[](#requirements)

- **php**: &gt;=7.4
- **psr/container**: ~1.0 || ~2.0

Installing
----------

[](#installing)

Install the latest version with:

```
composer require 'corpus/di'
```

Usage
-----

[](#usage)

Getting started with Di the three most important methods follow.

- The `set` method is used to set either the item to return or a lambda to lazily construct it, optionally taking constructor arguments.
- The `get` method is used to retrieve values with memoization after the initial lazy loading.
- The `getNew` is used to invoke the lazy loading creation lambda every call, optionally taking an array of constructor arguments as a second parameter.

```
