我想在注入類(資源庫)我app/Console/Kernel
:如何在Laravel的app/console/Kernel中注入一個類?
public function __construct(LocaleRepository $localeRepository)
{
$this->_localeRepository = $localeRepository;
}
不幸的是,我收到以下錯誤,這並不工作: PHP Fatal error: Uncaught Illuminate\Contracts\Container\BindingResolutionException: Target [App\Repositories\Interfaces\LocaleRepository] is not instantiable while building [App\Console\Kernel]. in /home/cv/cus/vendor/laravel/framework/src/Illuminate/Container/Container.php:895
我可以在注入庫控制器沒有任何問題。該庫還登記在服務提供商:
public function register()
{
$this->app->bind('App\Repositories\Interfaces\LocaleRepository', 'App\Repositories\Implementations\EloquentLocaleRepository');
}
是否有可能在app/console/Kernel
類注射類?
爲我工作,謝謝 – FosAvance