Skip to content

Latest commit

 

History

History
47 lines (34 loc) · 1.1 KB

README.md

File metadata and controls

47 lines (34 loc) · 1.1 KB

Laravel Autowire

Latest Stable Version Total Downloads tests

Usage

  1. Composer
composer require zhwei/laravel-autowire
  1. Register Service Provider (Lumen only)
$app->register(\Zhwei\LaravelAutowire\AutowireServiceProvider::class);
  1. 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);