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(4mo ago)1561MITPHPPHP &gt;=8.0

Since Oct 15Pushed 4mo 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 1mo ago

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

39

—

LowBetter than 86% of packages

Maintenance76

Regular maintenance activity

Popularity10

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity51

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

148d ago

Major Versions

v1.1.4 → v2.0.02025-12-22

### Community

Maintainers

![](https://www.gravatar.com/avatar/286460b133e6215e49b82b8f403d5ae59e542c58e7d6763f4c2d1072b374a59f?d=identicon)[lushaoming](/maintainers/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/telescope

An elegant debug assistant for the Laravel framework.

5.2k67.8M192](/packages/laravel-telescope)[spiral/roadrunner

RoadRunner: High-performance PHP application server and process manager written in Go and powered with plugins

8.4k12.2M84](/packages/spiral-roadrunner)[nolimits4web/swiper

Most modern mobile touch slider and framework with hardware accelerated transitions

41.8k177.2k1](/packages/nolimits4web-swiper)[laravel/dusk

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

1.9k36.7M259](/packages/laravel-dusk)[laravel/prompts

Add beautiful and user-friendly forms to your command-line applications.

708181.8M596](/packages/laravel-prompts)[cakephp/chronos

A simple API extension for DateTime.

1.4k47.7M121](/packages/cakephp-chronos)

PHPackages © 2026

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