Reputation: 10886
I'm using the laravel service container today for the first time. I know there is a lot to find on the internet about it but I can't find a solution for it. I'm trying to bind an interface to a class but when I do this I receive the error:
Target [App\contracts\UploadService] is not instantiable.
This is my service container called UploadServiceContainer:
<?php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
class UploadServiceProvider extends ServiceProvider
{
/**
* Bootstrap the application services.
*
* @return void
*/
public function boot()
{
//
}
/**
* Register the application services.
*
* @return void
*/
public function register()
{
$this->app->bind('App\Contracts\UploadService', 'App\Classes\upload\upload');
}
}
I try to instantiate it like this in my controller:
public function storeTicket(makeTicketRequest $request,UploadService $upload)
{ }
I've registered my Serviceprovider in app.php. And I've also done:
php artisan clear-compiled
Upvotes: 5
Views: 3558
Reputation: 62268
In your call to bind()
, you're using App\Contracts\UploadService
(capital "Contracts"), but the error message states App\contracts\UploadService
(lower "contracts"). Correct the discrepancy and it should work.
Upvotes: 2