laravel/framework · error · BindingResolutionException

Target [$concrete] is not instantiable while building…

Error message

Target [$concrete] is not instantiable while building [$previous].

What it means

BindingResolutionException from notInstantiable() when the container tries to build a non-instantiable type (interface, abstract class) as a transitive dependency of another class being built - i.e. buildStack is non-empty. The message lists the chain of classes already being constructed so you can see which dependency triggered it.

Solutions

  1. Bind the interface to a concrete implementation in a service provider: $this->app->bind(Contract::class, Implementation::class).
  2. Read the buildStack in the message to identify exactly which dependency is the abstract, then bind that one.
  3. If the abstract should resolve to itself, ensure it is a concrete instantiable class rather than an interface.
  4. Confirm the relevant service provider appears in config/app.php (or is auto-discovered for packages).

Example fix

// before
class InvoiceService
{
    public function __construct(private InvoiceRepo $repo) {} // InvoiceRepo is an interface
}
// after - in AppServiceProvider::register()
$this->app->bind(InvoiceRepo::class, DatabaseInvoiceRepo::class);
Defensive patterns

Strategy: validation

Validate before calling

// Before resolving a class with interface-typed dependencies, ensure bindings exist.
$r = new \ReflectionClass(Service::class);
foreach ($r->getConstructor()?->getParameters() ?? [] as $p) {
    $type = $p->getType();
    if ($type && ! $type->isBuiltin() && interface_exists($type->getName()) && ! app()->bound($type->getName())) {
        throw new RuntimeException("Interface [" . $type->getName() . "] required by [Service] is not bound.");
    }
}
app()->make(Service::class);

Type guard

function dependenciesAreBound(string $class, \Illuminate\Container\Container $c): bool
{
    $r = new \ReflectionClass($class);
    foreach ($r->getConstructor()?->getParameters() ?? [] as $p) {
        $t = $p->getType();
        if ($t && ! $t->isBuiltin() && (interface_exists($t->getName()) || (new \ReflectionClass($t->getName()))->isAbstract())
            && ! $c->bound($t->getName())) {
            return false;
        }
    }
    return true;
}

Try / catch

use Illuminate\Contracts\Container\BindingResolutionException;

try {
    $service = app()->make(Service::class);
} catch (BindingResolutionException $e) {
    if (str_contains($e->getMessage(), 'not instantiable while building')) {
        // read the build stack, bind the missing interface, retry
    }
    throw $e;
}

Prevention

When it happens

Trigger: Resolving a class whose constructor type-hints an interface that has no concrete binding; binding a concrete to an abstract but resolving a different consumer that depends on the abstract directly; forgetting to bind an interface in the provider for a nested dependency.

Common situations: Adding a new repository-interface dependency to a service but not binding the interface; environment where the service provider is not loaded; refactoring a class to depend on a contract that has no implementation registered.

Related errors


AI-assisted analysis of laravel/framework@e0f6eb3518 (2026-08-11). Data as JSON: /api/errors/70bf8bd65bb869d7. Report an issue: GitHub.

Appendix: source

Thrown at src/Illuminate/Container/Container.php:1436

    /**
     * Throw an exception that the concrete is not instantiable.
     *
     * @param  string  $concrete
     * @return void
     *
     * @throws \Illuminate\Contracts\Container\BindingResolutionException
     */
    protected function notInstantiable($concrete)
    {
        if (! empty($this->buildStack)) {
            $previous = implode(', ', $this->buildStack);

            $message = "Target [$concrete] is not instantiable while building [$previous].";
        } else {
            $message = "Target [$concrete] is not instantiable.";
        }

        throw new BindingResolutionException($message);
    }

    /**
     * Throw an exception for an unresolvable primitive.
     *
     * @return void
     *
     * @throws \Illuminate\Contracts\Container\BindingResolutionException
     */
    protected function unresolvablePrimitive(ReflectionParameter $parameter)
    {
        $message = "Unresolvable dependency resolving [$parameter] in class {$parameter->getDeclaringClass()->getName()}";

        throw new BindingResolutionException($message);
    }

    /**
     * Register a new before resolving callback for all types.

View on GitHub (pinned to e0f6eb3518)