Skip to content
/ di Public

A flexible dependency injection container based on the modification of illuminate/container. - 一个灵活的基于 illuminate/container 修改的依赖注入容器。

License

Notifications You must be signed in to change notification settings

guanguans/di

Repository files navigation

di

A flexible dependency injection container based on the modification of illuminate/container. - 一个灵活的基于 illuminate/container 修改的依赖注入容器。

Tests Check & fix styling codecov Latest Stable Version Total Downloads License

Requirement

  • PHP >= 5.6

Installation

$ composer require guanguans/di -vvv

Usage

<?php

require __DIR__.'/vendor/autoload.php';

class ConcreteStub{}

$container = new \Guanguans\Di\Container();

// Simple Bindings
$container->bind(ConcreteStub::class, function ($container) {
    return new ConcreteStub();
});

// Binding A Singleton
$container->singleton('ConcreteStub', function ($container) {
    return new ConcreteStub();
});

// Binding Interfaces To Implementations
$container->bind(
    'App\Contracts\EventPusher',
    'App\Services\RedisEventPusher'
);

// Resolving
$concreteStub = $container->make(ConcreteStub::class);

Testing

$ composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.

About

A flexible dependency injection container based on the modification of illuminate/container. - 一个灵活的基于 illuminate/container 修改的依赖注入容器。

Topics

Resources

License

Security policy

Stars

Watchers

Forks

Packages

No packages published

Languages