guanguans/di
A flexible dependency injection container based on the modification of `illuminate/container`. - 一个灵活的基于 `illuminate/container` 修改的依赖注入容器。
1,234
5
| Install | |
|---|---|
composer require guanguans/di |
|
| Latest Version: | v1.0.2 |
| PHP: | >=5.6.4 |
| License: | MIT |
| Last Updated: | Nov 16, 2020 |
| Links: | GitHub · Packagist |
Maintainer: guanguans
di
A flexible dependency injection container based on the modification of
illuminate/container. - 一个灵活的基于illuminate/container修改的依赖注入容器。
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.
Related Packages
solophp/inertia-svelte-skeleton
SoloPHP Framework Skeleton Application for Inertia.js and Svelte, ready to start...
0
1
mikescott/emissary
Allows you to easily use Laravel Service Providers with Slim 3's DI container
81
3
thecodingmachine/laravel-universal-service-provider
This Laravel service provider allows Laravel applications to use service provide...
11
2