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

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

artex/di-container
==================

A lightweight, PSR-11 compliant dependency injection and service container library with advanced features like tagged services, lifecycle hooks, and deferred services.

v1.0.0(1y ago)13Apache-2.0PHPPHP ^8.1

Since Jan 14Pushed 1y ago1 watchersCompare

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

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

   ![Artex Agency Logo](./docs/media/artex-agency-logo.png)
  **DI-CONTAINER
 artex software**
==================================================================================================

[](#--------------------------------------------di-container----------------artex-software----)

**A PSR-11 compliant dependency injection and service container library for modern PHP applications.**

 [ ![Latest Version](https://camo.githubusercontent.com/c3c5c0eba53a41ef9e4efcdbf1a398f1da8f9ccd7af1dbef96e10e9c6297652a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f61727465782f64692d636f6e7461696e6572) ](https://packagist.org/packages/artex/di-container) [ ![Total Downloads](https://camo.githubusercontent.com/ba81199292d134cede475ce047755a4aca70d770db5c0c46db029045844dc446/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f61727465782f64692d636f6e7461696e6572) ](https://packagist.org/packages/artex/di-container) [ ![License](https://camo.githubusercontent.com/39a434c39c97856247fc55ebc90e8cc1cb9871558a37bf1bf83cbaca3be89d69/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d417061636865253230322e302d626c7565) ](LICENSE)

---

Artex DI-Container is a lightweight, feature-rich library designed to simplify dependency management in PHP. Built with **high performance**, **flexibility**, and **extensibility** in mind, this library combines the power of dependency injection with a robust service container.

Key Features
------------

[](#key-features)

- **PSR-11 Compliant**: Adheres to the `ContainerInterface` standard for maximum interoperability.
- **Dependency Injection**: Autowire classes and resolve dependencies effortlessly.
- **Service Management**: Tagged services, lifecycle hooks, deferred loading, and more.
- **Flexibility**: Perfect for frameworks, microservices, or standalone applications.

---

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

[](#installation)

```
composer "require artex/di-container"
```

Usage
-----

[](#usage)

### Basic Example

[](#basic-example)

```
use Artex\DIContainer\ServiceContainer;

$container = ServiceContainer::getInstance();

// Register a shared service
$container->singleton('logger', function () {
    return new Logger();
});

// Resolve the service
$logger = $container->get('logger');
```

### Tagged Services

[](#tagged-services)

```
$container->set('handler1', new Handler1(), true, ['event']);
$container->set('handler2', new Handler2(), true, ['event']);

// Retrieve all services tagged with "event"
$handlers = $container->getByTag('event');
```

### Lifecycle Hooks

[](#lifecycle-hooks)

```
$container->onRegister(function ($id, $concrete, $shared) {
    echo "Service {$id} registered.\n";
});

$container->onResolve(function ($id, $instance) {
    echo "Service {$id} resolved.\n";
});

$container->singleton('db', function () {
    return new DatabaseConnection();
});
```

Testing
-------

[](#testing)

Run tests using PHPUnit:

```
./vendor/bin/phpunit
```

Credits
-------

[](#credits)

- [James Gober](https://github.com/jamesgober) - Developer
- [Artex Software](https://artexsoftware.com) - Sponsor

License
-------

[](#license)

The Apache License 2.0. Please see [LICENSE](LICENSE) file for more information.

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance41

Moderate activity, may be stable

Popularity5

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity47

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

Unknown

Total

1

Last Release

489d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/e09f360f8998d68822aca7bb668a16c70cd4f250e246e30252d2246d1449ac3b?d=identicon)[jamesgober](/maintainers/jamesgober)

---

Top Contributors

[![jamesgober](https://avatars.githubusercontent.com/u/12473969?v=4)](https://github.com/jamesgober "jamesgober (7 commits)")

---

Tags

artex-softwaredependency-injectiondi-containerlifecycle-hooksphppsr-11service-containertagged-servicesphpPSR-11di containerdependency-injectionservice containerlifecycle-hooksArtex-SoftwareArtex-AgencyArtexTagged Services

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/artex-di-container/health.svg)

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

###  Alternatives

[phpwatch/simple-container

A fast and minimal PSR-11 compatible Dependency Injection Container with array-syntax and without auto-wiring

1810.1k2](/packages/phpwatch-simple-container)

PHPackages © 2026

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