PHPackages                             stefna/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. [Utility &amp; Helpers](/categories/utility)
4. /
5. stefna/di

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

stefna/di
=========

Lightweight dependency injection container

1.3.0(1y ago)012.2k↓44.5%2MITPHPPHP ^8.2CI passing

Since Apr 4Pushed 5mo ago3 watchersCompare

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

READMEChangelog (4)Dependencies (9)Versions (13)Used By (2)

Dependency Injection
====================

[](#dependency-injection)

[![Build Status](https://github.com/stefna/di/actions/workflows/continuous-integration.yml/badge.svg?branch=main)](https://github.com/stefna/di/actions/workflows/continuous-integration.yml)[![Latest Version on Packagist](https://camo.githubusercontent.com/8d1a7ac0cb529e0b82483dab5a1555421d305714cb784903e75fe4d4c71eabf3/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f737465666e612f64692e737667)](https://packagist.org/packages/stefna/di)[![Software License](https://camo.githubusercontent.com/3c590a70fdf7030d2b863f4580b3f8fa66150ec36a8c7427e2193494b5aa7a23/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f737465666e612f64692e737667)](LICENSE)

This package is a lightweight dependency injection container that is framework-agnostic.

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

[](#requirements)

PHP 8.2 or higher.

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

[](#installation)

```
composer require stefna/di
```

Usage
-----

[](#usage)

You will always have to use the `ContainerBuilder` to create a `Container`since we don't do any automatic autowiring, so you will have to define everything you want to have access to

### Configure container

[](#configure-container)

To configure you container you add `DefinitionSource`'s to the container builder.

```
