laravel/framework · error · BindingResolutionException

Target class [$concrete] does not exist.

Error message

Target class [$concrete] does not exist.

What it means

Thrown by Container::build when the concrete class string passed in cannot be reflected because the class does not exist. Reflection throws ReflectionException, which Laravel wraps in BindingResolutionException with the class name so users get a clear 'Target class [$concrete] does not exist.' This is the classic 'class not found' for auto-resolution.

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 bd6b5437e6)

Solutions

  1. Run composer dump-autoload to refresh the autoloader after adding/renaming classes.
  2. Verify the class name and namespace in a grep/IDE — fix typos and stale references.
  3. Ensure the package providing the class is in require (not just require-dev) if used outside tests.
  4. Register an explicit binding for the abstract: $this->app->bind(MissingContract::class, RealImpl::class).

Example fix

// before
app()->make(\App\Services\StripePaymet::class); // typo

// after
app()->make(\App\Services\StripePayment::class);
Defensive patterns

Strategy: validation

Validate before calling

if (! class_exists($class)) {
    throw new \InvalidArgumentException("Class {$class} not found; run composer dump-autoload");
}
app()->make($class);

Type guard

function isResolvableClass(string $class): bool
{
    return class_exists($class) || interface_exists($class);
}

Try / catch

use Illuminate\Contracts\Container\BindingResolutionException;
try {
    app()->make($class);
} catch (BindingResolutionException $e) {
    if (str_contains($e->getMessage(), 'does not exist')) {
        // run composer dump-autoload or bind a fallback
    }
    throw $e;
}

Prevention

When it happens

Trigger: Calling app()->make('App\Services\MissingService') for a non-existent class; binding a typo'd class string; namespace change without composer dump-autoload; using a class from a package that is not installed; facades/providers referencing deleted classes.

Common situations: After renaming or moving a class without updating references; missing composer package; wrong namespace in config/app.php providers array; PSR-4 autoload path mismatch; class exists only in dev dependencies (e.g. phpunit helper) and is referenced in production.

Related errors


AI-assisted analysis of laravel/framework@bd6b5437e6 (2026-08-06). Data as JSON: /data/errors/e6701da5d399eeb9.json. Report an issue: GitHub.