{"record":{"id":"053878104327b56f","repo":"barryvdh/laravel-ide-helper","slug":"class-class-not-found","errorCode":null,"errorMessage":"Class '$class' not found.","messagePattern":"Class '\\$class' not found\\.","errorType":"exception","errorClass":"ReflectionException","httpStatus":null,"severity":"error","filePath":"src/Console/MetaCommand.php","lineNumber":210,"sourceCode":"        $autoloader = function ($class) use ($aliases) {\n            // ignore aliases as they're meant to be resolved elsewhere\n            if (in_array($class, $aliases, true)) {\n                return;\n            }\n\n            // Don't throw when class existence is being checked via class_exists(),\n            // interface_exists(), trait_exists(), or enum_exists(). These functions\n            // expect the autoloader to return gracefully when the class doesn't exist.\n            // Throwing here would break libraries that use class_exists() to check for\n            // optional dependencies (e.g. Doctrine ORM checking for removed classes).\n            $existsFunctions = ['class_exists', 'interface_exists', 'trait_exists', 'enum_exists'];\n            foreach (debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 3) as $frame) {\n                if (isset($frame['function']) && in_array($frame['function'], $existsFunctions, true)) {\n                    return;\n                }\n            }\n\n            throw new \\ReflectionException(\"Class '$class' not found.\");\n        };\n\n        spl_autoload_register($autoloader);\n\n        return $autoloader;\n    }\n\n    protected function getExpectedArgumentSets()\n    {\n        return [\n            'auth' => $this->loadTemplate('auth')->keys()->filter()->toArray(),\n            'configs' => $this->loadTemplate('configs')->pluck('name')->filter()->toArray(),\n            'middleware' => $this->loadTemplate('middleware')->keys()->filter()->toArray(),\n            'routes' => $this->loadTemplate('routes')->pluck('name')->filter()->toArray(),\n            'views' => $this->loadTemplate('views')->pluck('key')->filter()->map(function ($value) {\n                return (string) $value;\n            })->toArray(),\n            'translations' => $this->loadTemplate('translations')->filter()->keys()->toArray(),","sourceCodeStart":192,"sourceCodeEnd":228,"githubUrl":"https://github.com/barryvdh/laravel-ide-helper/blob/3a886dca5c7ec4854b316b1ac3bcdf9c43c1760b/src/Console/MetaCommand.php#L192-L228","documentation":"Thrown by a temporary autoloader that ide-helper:meta registers while it resolves every container binding (src/Console/MetaCommand.php:188-216). Its purpose is to turn a silent autoload miss into a loud ReflectionException naming the missing class, so broken bindings surface during meta generation instead of producing an incomplete .php.meta file. It stays quiet only when the miss originates from class_exists()/interface_exists()/trait_exists()/enum_exists(), which expect a graceful return. In practice the message tells you that some class referenced by a container binding, provider, or config value cannot be autoloaded.","triggerScenarios":"Running `php artisan ide-helper:meta` when a bound concrete class does not exist: composer dependencies not installed, an optimized/stale autoloader still pointing at deleted files, a service provider or config entry referencing a class from a package that was removed or renamed, or vendor code that instantiates an optional dependency without a class_exists() guard. The throw happens only when the missing class is actually used (instantiated/reflected), not merely existence-checked.","commonSituations":"CI or fresh clone where `composer install` was skipped or ran with --no-dev; after deleting a package while keeping its ProviderEntry in config/app.php or bootstrap/providers.php; after a major Laravel/package upgrade that moved or renamed classes while composer dump-autoload -o caches old paths; a config value (e.g. auth.model or a custom binding) pointing at a deleted model namespace.","solutions":["Run `composer install` (or `composer dump-autoload -o`) so the autoloader maps every installed class, then retry `php artisan ide-helper:meta -v`.","Re-run with -v/--verbose: the wrapping 'Cannot make ...' comment in handle() prints the abstract name together with this ReflectionException message, telling you exactly which class is missing.","Search the codebase and config for the missing class name (config/app.php providers, bootstrap/providers.php, Auth model config, custom service providers) and remove or update the stale reference.","If the class belongs to an optional package, either reinstall the package (`composer require vendor/pkg`) or make the binding/provider conditional on class_exists().","If names were moved by a framework upgrade, update the imports in your own providers and re-run `composer dump-autoload`."],"exampleFix":"# before: stale provider references a removed package class\n# config/app.php\nApp\\Providers\\OldSmsProvider::class,  # binds App\\Services\\Sms\\Sender which no longer exists\n$ php artisan ide-helper:meta\nClass 'App\\Services\\Sms\\Sender' not found.\n\n# after: drop the dead provider and refresh the autoloader\n# config/app.php\n# (OldSmsProvider removed)\n$ composer dump-autoload -o && php artisan ide-helper:meta -v","handlingStrategy":"try-catch","validationCode":"// Preflight before ide-helper:meta: surface bindings that cannot resolve\n$failures = [];\nforeach (array_keys(app()->getBindings()) as $abstract) {\n    try {\n        app()->make($abstract);\n    } catch (\\Throwable $e) {\n        $failures[] = $abstract . ' => ' . $e->getMessage();\n    }\n}\nif ($failures) {\n    fwrite(STDERR, implode(\"\\n\", $failures) . \"\\n\");\n    exit(1); // fix composer autoload / stale references before generating\n}","typeGuard":null,"tryCatchPattern":"try {\n    \\Artisan::call('ide-helper:meta', ['--verbose' => true]);\n} catch (\\ReflectionException $e) {\n    // getMessage() names the missing class; repair vendor/config and re-run\n    report($e);\n}","preventionTips":["Always run `composer install` from composer.lock before generation commands, especially in CI.","After removing a package, re-run `composer dump-autoload -o` and grep config/app.php, bootstrap/providers.php and custom config for the removed namespace.","Make bindings of optional packages conditional: register the provider only when class_exists() on the package class.","Run ide-helper:meta with -v in CI so 'Cannot make ...' diagnostics are visible."],"tags":["php","laravel","ide-helper","autoloader","class-not-found","composer"],"backgroundTag":"class-not-found","analyzedSha":"3a886dca5c7ec4854b316b1ac3bcdf9c43c1760b","analyzedAt":"2026-08-23T00:48:42.471Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}