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

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

outboardphp/di
==============

PSR-11 Dependency Injection Container

v0.0.1(1mo ago)20MPL-2.0PHPPHP &gt;=8.4

Since Mar 29Pushed 1mo ago1 watchersCompare

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

READMEChangelog (1)Dependencies (12)Versions (2)Used By (0)

Outboard DI Container
=====================

[](#outboard-di-container)

A lightweight, composable IoC/dependency injection container for PHP, usable on its own or as part of the Outboard Framework.

This is the `outboardphp/di` package from the Outboard monorepo. It can be used standalone or as part of the full framework.

Design principles
-----------------

[](#design-principles)

- Respect SOLID principles, especially SRP, more than most other DI libraries
- Use a minimum of "magic" so that it is straightforward to understand
- Be powerful, flexible, and feature-rich, yet also fast and efficient
- Support a modular/layered architecture, allowing for simplified configuration by multiple packages
- Build on the work of [Level-2/Dice](https://github.com/Level-2/Dice), updating it for modern PHP and adding a few features from other libraries

Status
------

[](#status)

Pre-alpha. Stable enough to experiment with, but APIs may still evolve. Feel free to try it and report bugs.

Implemented features:

- Service retrieval and factory-style creation (`get()` / `make()`)
- Shared and non-shared lifecycles (`shared`, prototype-by-default)
- Constructor parameter overrides (`withParams()` by name or position)
- Callable invocation with dependency resolution (`call()`)
- Optional autowiring via resolver strategy (`AutowiringResolver`)
- Definition inheritance across class/interface hierarchies (`strict` to opt out)
- Parent-container fallback for dependency resolution (`setParent()`)

Current missing features (planned):

- Service tagging retrieval (`getTagged()` / tag queries)
- Type-based parameter matching in `withParams`
- Lazy services / lazy proxies
- Runtime circular dependency detection with cycle-path errors
- Parameter resolution for container-wide config values
- Parameterized `make()` runtime constructor overrides

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

[](#requirements)

- PHP `>=8.4`
- Composer `2.x`

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

[](#installation)

```
composer require outboardphp/di
```

Quick Start
-----------

[](#quick-start)

Preferred usage is via `ContainerFactory` with a `DefinitionProvider`. You can implement `DefinitionProvider` in your own way to achieve a variety of strategies of loading definitions.

```
