friendsofhyperf / di-plus
The di plus component for Hyperf.
Fund package maintenance!
huangdijia
hdj.me/sponsors
Requires
- hyperf/dispatcher: ~3.1.0
This package is auto-updated.
Last update: 2024-10-25 03:47:41 UTC
README
The di plus component for Hyperf.
Installation
composer require friendsofhyperf/di-plus
Usage
<?php // config/autoload/dependencies.php return [ 'App\Bar@App\Foo1' => App\BarAtFoo1Factory::class, 'App\Bar@App\Foo2' => App\BarAtFoo2Factory::class, ];
<?php namespace App; class Foo1 { public function __construct(public Bar $bar) { } } class Foo2 { public function __construct(public Bar $bar) { } }
支持注解的方式
<?php namespace App; use Hyperf\Di\Annotation\Inject; class Foo1 { #[Inject] public Bar $bar; } class Foo2 { #[Inject] public Bar $bar; }