Answer the question
In order to leave comments, you need to log in
Class initialization error in provider?
View error:
Target [App\Services\OrderServiceInterface] is not instantiable.
public function register()
{
$this->app->bind('App\Services\OrderServiceInterface', OrderService::class);
}
<?php
namespace App\Services;
interface OrderServiceInterface
{
public function doSomethingUseful();
}
<?php
namespace App\Services;
class OrderService implements OrderServiceInterface
{
public function doSomethingUseful()
{
return 'Output from DemoOne';
}
}
Answer the question
In order to leave comments, you need to log in
This error means that Laravel cannot find the binding.
First of all check that you are calling it via an interface, i.e.
public function __construct(OrderServiceInterface $orderService)
{
...
$reflector = new ReflectionClass($concrete);
// If the type is not instantiable, the developer is attempting to resolve
// an abstract type such as an Interface of Abstract Class and there is
// no binding registered for the abstractions so we need to bail out.
if (! $reflector->isInstantiable()) {
return $this->notInstantiable($concrete);
}
...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question