{"record":{"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/e0f6eb3518ac29fbbca8529e97d0df7fc9f24481/src/Illuminate/Container/Container.php#L1129-L1165","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Correct the class name / namespace in the binding, controller, or route.","Run composer dump-autoload to refresh the autoloader after adding or moving classes.","Ensure the class file exists at the PSR-4 expected path and the package is installed.","Inspect $e->getPrevious() (the ReflectionException) for the precise class name that failed."],"exampleFix":"// before\n$app->bind(InvoiceRepo::class, 'App\\Billing\\InvoiceRepository'); // wrong namespace\n// after\n$app->bind(InvoiceRepo::class, 'App\\Repositories\\InvoiceRepository');","handlingStrategy":"validation","validationCode":"// Validate a class string before binding/resolving.\nif (! class_exists($concrete)) {\n    throw new RuntimeException(\"Target class [$concrete] does not exist. Check namespace/autoloader.\");\n}\n$container->bind($abstract, $concrete);","typeGuard":"function targetClassExists(string $concrete): bool\n{\n    return class_exists($concrete);\n}","tryCatchPattern":"use Illuminate\\Contracts\\Container\\BindingResolutionException;\n\ntry {\n    $instance = $container->make($abstract);\n} catch (BindingResolutionException $e) {\n    if (str_contains($e->getMessage(), 'does not exist')) {\n        // run composer dump-autoload, fix namespace, then retry\n    }\n    throw $e;\n}","preventionTips":["Run composer dump-autoload after adding/moving classes.","Use ::class constants instead of string literals to get compile-time-checked FQCNs.","Lint service providers/routes for class strings that don't resolve via class_exists()."],"tags":["container","reflection","autoloading","binding"],"backgroundTag":null,"analyzedSha":"e0f6eb3518ac29fbbca8529e97d0df7fc9f24481","analyzedAt":"2026-08-11T20:52:37.562Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}