I have service provider:
<?php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
class InvitationServiceProvider extends ServiceProvider
{
/**
* Register services.
*
* @return void
*/
public function register()
{
$this->app->bind('App\Service\InvitationServiceInterface', 'App\Service\InvitationService');
}
/**
* Bootstrap services.
*
* @return void
*/
public function boot()
{
//
}
}
Also there is an custom interface InvitationServiceInterface and InvitationService:
<?php
namespace App\Service;
class InvitationService implements InvitationServiceInterface
{
public function doAwesomeThing()
{
echo 'Do...';
}
}
Interface is:
<?php
namespace App\Service;
interface InvitationServiceInterface
{
public function doAwesomeThing();
}
These both files are place in path:
App\Service\InvitationServiceInterface
App\Service\InvitationService
So, I get an error:
Illuminate \ Contracts \ Container \ BindingResolutionException Target [App\Service\InvitationServiceInterface] is not instantiable.
Using is:
use App\Service\InvitationServiceInterface;
use App\User;
use Illuminate\Http\Request;
class PassportController extends Controller
{
public function register(Request $request, InvitationServiceInterface $invitationService)
{
}
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire