dimanche 9 juillet 2017

How to inject a class in the app/console/Kernel in Laravel?

I'm trying to inject a class (a repository) in my app/Console/Kernel:

public function __construct(LocaleRepository $localeRepository)
{
    $this->_localeRepository = $localeRepository;
}

Unfortunately this doesn't work as I receive the following error: 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

I can inject the repository in controllers without any problem. The repository is also registered in the service provider:

public function register()
{
    $this->app->bind('App\Repositories\Interfaces\LocaleRepository', 'App\Repositories\Implementations\EloquentLocaleRepository');
}

Is it possible to inject a class in the app/console/Kernel class?



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2sUeVTS
via IFTTT

Aucun commentaire:

Enregistrer un commentaire