PHPackages                             stougeiro/container-contract - 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. [Framework](/categories/framework)
4. /
5. stougeiro/container-contract

ActiveLibrary[Framework](/categories/framework)

stougeiro/container-contract
============================

Interfaces and contracts for implementing dependency injection containers in PHP, covering lifecycle handling, service resolution and factory-based instantiation.

v1.0.1(today)02↑2900%MITPHPPHP &gt;=8.1

Since Jul 31Pushed todayCompare

[ Source](https://github.com/stougeiro/container-contract)[ Packagist](https://packagist.org/packages/stougeiro/container-contract)[ Fund](https://www.buymeacoffee.com/stougeiro)[ RSS](/packages/stougeiro-container-contract/feed)WikiDiscussions master Synced today

READMEChangelog (2)Dependencies (2)Versions (3)Used By (0)

[![phpstan-level](https://camo.githubusercontent.com/942bdbddc7b2adea1d63ed80793492d06d72ef41911edcba33310d0745581548/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048505374616e2d4c6576656c253230392d627269676874677265656e)](https://camo.githubusercontent.com/942bdbddc7b2adea1d63ed80793492d06d72ef41911edcba33310d0745581548/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048505374616e2d4c6576656c253230392d627269676874677265656e)

Container Contract
==================

[](#container-contract)

A set of stable, framework‑independent contracts that define the core abstractions required to implement dependency injection containers in PHP.

These interfaces establish consistent patterns for service registration, lifecycle management, resolution strategies, and factory‑based instantiation, allowing different container implementations to share a common foundation.

The goal of this package is to provide clear, explicit, and SOLID‑oriented contracts that can be adopted by any container, framework, or modular application architecture.

✨ Features
----------

[](#-features)

- **PSR‑11 compatible**
    Fully aligned with `Psr\Container\ContainerInterface`, ensuring interoperability with existing tooling.
- **Explicit service registration**
    Register services using clear, intention‑revealing methods: `set()`, `bind()`, and `singleton()` — no autowiring, no magic.
- **Factory‑based instantiation**
    Classes may implement `ServiceFactoryInterface` to control their own creation logic, ensuring predictable and testable instantiation.
- **Provider lifecycle management**
    ServiceProviderInterface defines `register()`, `boot()`, and `terminate()` phases, enabling modular initialization and teardown.
- **Framework‑agnostic design**
    Contracts do not assume any specific container implementation, allowing different ecosystems to adopt and extend them freely.

---

📦 Installation
--------------

[](#-installation)

Install via Composer:

```
composer require stougeiro/container-contract
```

🔧 Implementations
-----------------

[](#-implementations)

These contracts are designed to be implemented by any dependency injection container or modular application architecture. Below is a list of known implementations maintained by the community.

- `stougeiro/container`
    Repository:

---

🧠 Why?
------

[](#-why)

Because dependency injection should be explicit, predictable, and framework‑independent.

Most containers rely on autowiring, reflection, or implicit resolution rules that make applications harder to reason about, harder to test, and harder to maintain over time.

These contracts take the opposite approach:

- No autowiring
- No reflection magic
- No hidden behavior

By defining clear, stable interfaces, we separate what a container or provider does from how it is implemented. This allows different containers, modules, and applications to interoperate without being tightly coupled to a specific framework or resolution strategy.

---

🤝 Contributions
---------------

[](#-contributions)

Contributions are welcome. Feel free to open issues or submit pull requests.

[![](https://camo.githubusercontent.com/0cf29a542375e1a46e84d8bf5805a4e5c0a6ee98b6547ccdc0c55eed49d99c69/68747470733a2f2f63646e2e6275796d6561636f666665652e636f6d2f627574746f6e732f76322f64656661756c742d79656c6c6f772e706e67)](https://www.buymeacoffee.com/stougeiro)

###  Health Score

40

—

FairBetter than 86% of packages

Maintenance100

Actively maintained with recent releases

Popularity3

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity43

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~0 days

Total

2

Last Release

0d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/3516412?v=4)[S.Tougeiro](/maintainers/stougeiro)[@stougeiro](https://github.com/stougeiro)

---

Top Contributors

[![stougeiro](https://avatars.githubusercontent.com/u/3516412?v=4)](https://github.com/stougeiro "stougeiro (10 commits)")

---

Tags

psrphpcontainerframeworkinterfacescontractsdependency-injectiondiservice containeragnostic

###  Code Quality

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/stougeiro-container-contract/health.svg)

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

###  Alternatives

[laravel/framework

The Laravel Framework.

34.8k556.2M20.8k](/packages/laravel-framework)[symfony/symfony

The Symfony PHP framework

31.4k87.4M2.2k](/packages/symfony-symfony)[joomla/di

Joomla DI Package

16445.0k13](/packages/joomla-di)[infocyph/intermix

A lightweight PHP DI container, invoker, serializer, and utility toolkit.

137.7k4](/packages/infocyph-intermix)

PHPackages © 2026

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