PHPackages                             yolo-fx/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. [Framework](/categories/framework)
4. /
5. yolo-fx/di

ActiveLibrary[Framework](/categories/framework)

yolo-fx/di
==========

A PHP dependency injection package.

v2.0.0(6mo ago)2571MITPHPPHP &gt;=8.0

Since Oct 15Pushed 5mo ago1 watchersCompare

[ Source](https://github.com/lushaoming/yolo-fx-di)[ Packagist](https://packagist.org/packages/yolo-fx/di)[ RSS](/packages/yolo-fx-di/feed)WikiDiscussions main Synced today

READMEChangelog (10)DependenciesVersions (14)Used By (1)

YOLO DI
=======

[](#yolo-di)

YOLO DI is a lightweight PHP dependency injection (DI) library designed to simplify the process of managing dependencies, resolving classes, and injecting properties. It provides a static facade for interacting with the DI container, making it easy to bind, resolve, and manage object lifecycles.

Features
--------

[](#features)

- **Dependency Resolution**: Automatically resolve and instantiate classes with their dependencies.
- **Class Binding**: Bind interfaces or abstract classes to concrete implementations.
- **Instance Management**: Manually set or remove specific instances for classes.
- **Alias Management**: Create and manage aliases for classes.
- **Custom Property Injection**: Use attributes to inject custom dependencies into class properties.

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

[](#installation)

To install YOLO DI, use Composer:

```
composer require yolo-fx/di
```

Usage
-----

[](#usage)

### Basic Example

[](#basic-example)

```
use Yolo\Di\DI;

DI::bind(LoggerInterface::class, ConsoleLogger::class);

$logger = DI::use(LoggerInterface::class);
$logger->log("Hello, World!");
```

### Using Aliases

[](#using-aliases)

```
DI::alias(TestRunner::class, 'runner');

$runner = DI::use('runner');
$runner->sayHello();
```

### Custom Property Injection

[](#custom-property-injection)

Define a custom attribute:

```
#[Attribute]
class Cache implements \Yolo\Di\PropertyAttributeInterface
{
    public function __construct(private string $driver = 'default') {}

    public function inject(): mixed
    {
        return match ($this->driver) {
            'file' => DI::use(FileLogger::class),
            default => DI::use(ConsoleLogger::class),
        };
    }
}
```

Use the attribute in a class:

```
class TestRunner
{
    public function __construct(
        #[Cache('file')]
        private LoggerInterface $logger
    ) {}

    public function sayHello(): void
    {
        $this->logger->log("Hello, World!");
    }
}
```

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

[](#requirements)

- PHP 8.0 or higher

License
-------

[](#license)

This project is licensed under the MIT License. See the `LICENSE` file for details.

Author
------

[](#author)

- **LUSHAOMING** -

###  Health Score

38

—

LowBetter than 83% of packages

Maintenance69

Regular maintenance activity

Popularity11

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity52

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 ~39 days

Recently: every ~100 days

Total

12

Last Release

194d ago

Major Versions

v1.1.4 → v2.0.02025-12-22

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/20497228?v=4)[lushaoming](/maintainers/lushaoming)[@lushaoming](https://github.com/lushaoming)

---

Top Contributors

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

### Embed Badge

![Health badge](/badges/yolo-fx-di/health.svg)

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

###  Alternatives

[laravel/dusk

Laravel Dusk provides simple end-to-end testing and browser automation.

1.9k39.6M299](/packages/laravel-dusk)[nineinchnick/edatatables

Grid widget for the Yii Framework, wrapper for the DataTables jQuery plugin

173.2k](/packages/nineinchnick-edatatables)[link-cloud/fast-hyperf

LinkCloud Fast Hyperf

241.2k1](/packages/link-cloud-fast-hyperf)

PHPackages © 2026

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