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
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With