{"id":"e6701da5d399eeb9","repo":"laravel/framework","slug":"target-class-concrete-does-not-exist","errorCode":null,"errorMessage":"Target class [$concrete] does not exist.","messagePattern":"Target class \\[\\$concrete\\] does not exist\\.","errorType":"exception","errorClass":"BindingResolutionException","httpStatus":null,"severity":"error","filePath":"src/Illuminate/Container/Container.php","lineNumber":1147,"sourceCode":"    public function build($concrete)\n    {\n        // If the concrete type is actually a Closure, we will just execute it and\n        // hand back the results of the functions, which allows functions to be\n        // used as resolvers for more fine-tuned resolution of these objects.\n        if ($concrete instanceof Closure) {\n            $this->buildStack[] = spl_object_hash($concrete);\n\n            try {\n                return $concrete($this, $this->getLastParameterOverride());\n            } finally {\n                array_pop($this->buildStack);\n            }\n        }\n\n        try {\n            $reflector = new ReflectionClass($concrete);\n        } catch (ReflectionException $e) {\n            throw new BindingResolutionException(\"Target class [$concrete] does not exist.\", 0, $e);\n        }\n\n        // If the type is not instantiable, the developer is attempting to resolve\n        // an abstract type such as an Interface or Abstract Class and there is\n        // no binding registered for the abstractions so we need to bail out.\n        if (! $reflector->isInstantiable()) {\n            return $this->notInstantiable($concrete);\n        }\n\n        if (is_a($concrete, SelfBuilding::class, true) &&\n            ! in_array($concrete, $this->buildStack, true)) {\n            return $this->buildSelfBuildingInstance($concrete, $reflector);\n        }\n\n        $this->buildStack[] = $concrete;\n\n        $constructor = $reflector->getConstructor();\n","sourceCodeStart":1129,"sourceCodeEnd":1165,"githubUrl":"https://github.com/laravel/framework/blob/bd6b5437e6ad87bb49f9b426724f07a9f64e9683/src/Illuminate/Container/Container.php#L1129-L1165","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Run composer dump-autoload to refresh the autoloader after adding/renaming classes.","Verify the class name and namespace in a grep/IDE — fix typos and stale references.","Ensure the package providing the class is in require (not just require-dev) if used outside tests.","Register an explicit binding for the abstract: $this->app->bind(MissingContract::class, RealImpl::class)."],"exampleFix":"// before\napp()->make(\\App\\Services\\StripePaymet::class); // typo\n\n// after\napp()->make(\\App\\Services\\StripePayment::class);","handlingStrategy":"validation","validationCode":"if (! class_exists($class)) {\n    throw new \\InvalidArgumentException(\"Class {$class} not found; run composer dump-autoload\");\n}\napp()->make($class);","typeGuard":"function isResolvableClass(string $class): bool\n{\n    return class_exists($class) || interface_exists($class);\n}","tryCatchPattern":"use Illuminate\\Contracts\\Container\\BindingResolutionException;\ntry {\n    app()->make($class);\n} catch (BindingResolutionException $e) {\n    if (str_contains($e->getMessage(), 'does not exist')) {\n        // run composer dump-autoload or bind a fallback\n    }\n    throw $e;\n}","preventionTips":["Run composer dump-autoload after class renames.","Use ::class constants instead of string literals.","Static analysis (phpstan) flags unknown classes."],"tags":["container","class-not-found","autoload","di"],"analyzedSha":"bd6b5437e6ad87bb49f9b426724f07a9f64e9683","analyzedAt":"2026-08-06T00:28:32.783Z","schemaVersion":2}