laravel/framework · error · BindingResolutionException

Target class [$concrete] does not exist.

Error message

Target class [$concrete] does not exist.

What it means

BindingResolutionException thrown during build() when new ReflectionClass($concrete) raises a ReflectionException, meaning the class string does not correspond to a loadable class. The container wraps the ReflectionException so callers see a domain-level binding error naming the missing target.

Solutions

  1. Correct the class name / namespace in the binding, controller, or route.
  2. Run composer dump-autoload to refresh the autoloader after adding or moving classes.
  3. Ensure the class file exists at the PSR-4 expected path and the package is installed.
  4. Inspect $e->getPrevious() (the ReflectionException) for the precise class name that failed.

Example fix

// before
$app->bind(InvoiceRepo::class, 'App\Billing\InvoiceRepository'); // wrong namespace
// after
$app->bind(InvoiceRepo::class, 'App\Repositories\InvoiceRepository');
Defensive patterns

Strategy: validation

Validate before calling

// Validate a class string before binding/resolving.
if (! class_exists($concrete)) {
    throw new RuntimeException("Target class [$concrete] does not exist. Check namespace/autoloader.");
}
$container->bind($abstract, $concrete);

Type guard

function targetClassExists(string $concrete): bool
{
    return class_exists($concrete);
}

Try / catch

use Illuminate\Contracts\Container\BindingResolutionException;

try {
    $instance = $container->make($abstract);
} catch (BindingResolutionException $e) {
    if (str_contains($e->getMessage(), 'does not exist')) {
        // run composer dump-autoload, fix namespace, then retry
    }
    throw $e;
}

Prevention

When it happens

Trigger: Binding an abstract to a misspelled or non-existent class string; resolving a class that lives in a package not installed/composer-autoloaded; namespace typo in a service provider or controller FQCN.

Common situations: Class renamed/moved during refactor but binding string not updated; composer dump-autoload not run after adding a class; package removed from composer.json but still referenced; wrong namespace prefix in module/plugin registration.

Related errors


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

Appendix: source

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

    public function build($concrete)
    {
        // If the concrete type is actually a Closure, we will just execute it and
        // hand back the results of the functions, which allows functions to be
        // used as resolvers for more fine-tuned resolution of these objects.
        if ($concrete instanceof Closure) {
            $this->buildStack[] = spl_object_hash($concrete);

            try {
                return $concrete($this, $this->getLastParameterOverride());
            } finally {
                array_pop($this->buildStack);
            }
        }

        try {
            $reflector = new ReflectionClass($concrete);
        } catch (ReflectionException $e) {
            throw new BindingResolutionException("Target class [$concrete] does not exist.", 0, $e);
        }

        // If the type is not instantiable, the developer is attempting to resolve
        // an abstract type such as an Interface or Abstract Class and there is
        // no binding registered for the abstractions so we need to bail out.
        if (! $reflector->isInstantiable()) {
            return $this->notInstantiable($concrete);
        }

        if (is_a($concrete, SelfBuilding::class, true) &&
            ! in_array($concrete, $this->buildStack, true)) {
            return $this->buildSelfBuildingInstance($concrete, $reflector);
        }

        $this->buildStack[] = $concrete;

        $constructor = $reflector->getConstructor();

View on GitHub (pinned to e0f6eb3518)