zhwei / laravel-autowire
Laravel Autowire Kit
1.1.0
2020-09-10 12:37 UTC
Requires
- php: ^7.2
- illuminate/support: ^6.0 || ^7.0 || ^8.0
- php-di/phpdoc-reader: ^2.1
Requires (Dev)
- laravel/laravel: ^6.0 || ^7.0 || ^8.0
- phpunit/phpunit: ^9.3
This package is auto-updated.
Last update: 2024-10-27 12:36:45 UTC
README
Usage
- Composer
composer require zhwei/laravel-autowire
- Register Service Provider (Lumen only)
$app->register(\Zhwei\LaravelAutowire\AutowireServiceProvider::class);
- Autowire
Any class implemented the Zhwei\LaravelAutowire\AutowireAble
interface will trigger auto-wire after container resolution.
class HelloController implements Zhwei\LaravelAutowire\AutowireAble { /** * @autowire * @var \Illuminate\Contracts\Cache\Factory */ protected $cache; public function hello() { return $this->cache->store()->get('hello'); } }
or trigger by your self:
$hello = new HelloController(); Zhwei\LaravelAutowire\AutowireInjector::inject(app(), $hello);