{"record":{"id":"64f535f0db72f1d0","repo":"barryvdh/laravel-ide-helper","slug":"cannot-load-template-for-name-message","errorCode":null,"errorMessage":"Cannot load template for {name}: {message}","messagePattern":"Cannot load template for (.+?): (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/Console/MetaCommand.php","lineNumber":336,"sourceCode":"                'class' => '\\Illuminate\\Support\\Env',\n                'method' => 'get',\n                'argumentSet' => 'env',\n            ],\n        ];\n    }\n\n    /**\n     * @return Collection\n     */\n    protected function loadTemplate($name)\n    {\n        if (!isset($this->templateCache[$name])) {\n            $file =  __DIR__ . '/../../php-templates/' . basename($name) . '.php';\n            try {\n                $value = $this->files->requireOnce($file) ?: [];\n            } catch (\\Throwable $e) {\n                $value = [];\n                $this->warn('Cannot load template for ' . $name . ': ' . $e->getMessage());\n            }\n\n            if (!$value instanceof Collection) {\n                $value = collect($value);\n            }\n            $this->templateCache[$name] = $value;\n        }\n\n        return $this->templateCache[$name];\n    }\n\n    /**\n     * Get the console command options.\n     *\n     * @return array\n     */\n    protected function getOptions()\n    {","sourceCodeStart":318,"sourceCodeEnd":354,"githubUrl":"https://github.com/barryvdh/laravel-ide-helper/blob/3a886dca5c7ec4854b316b1ac3bcdf9c43c1760b/src/Console/MetaCommand.php#L318-L354","documentation":"While generating the PhpStorm meta file, ide-helper:meta loads static templates (auth, configs, middleware, routes, views, translations) from the package's php-templates/ directory via requireOnce (src/Console/MetaCommand.php:326-340). Any Throwable raised while including the template file is caught and downgraded to this console warning, and the template is replaced with an empty collection. It is a warning, not an abort: the meta file is still written, but the affected expectedArguments set will be empty, so PhpStorm loses completion for that group.","triggerScenarios":"The template file `php-templates/{name}.php` does not exist under the installed package (Illuminate's Filesystem::requireOnce throws FileNotFoundException), the vendor directory is partially copied or a file was stripped by a deployment filter, or the template file itself throws at include time (parse-level issue after a bad patch, or an artisan call inside the template failing in an exotic environment).","commonSituations":"Docker images or PHAR bundlers that prune vendor/ and accidentally drop the php-templates folder; a partially completed `composer update` interrupted mid-write; custom forks of the package where a template was renamed; running generation on a mount where file permissions block reading the template.","solutions":["Check the embedded message: 'file does not exist' points at a missing template file; another message points at a failure inside the template's own code.","Restore the package intact: `composer reinstall barryvdh/laravel-ide-helper` (Composer >= 2.4), or delete vendor/barryvdh and rerun `composer install`.","Verify the folder exists and is readable: `ls vendor/barryvdh/laravel-ide-helper/php-templates/` should list auth.php, configs.php, middleware.php, routes.php, views.php, translations.php.","If you forked or patched the package, make sure every loadTemplate('...') name maps to an existing php-templates/{name}.php file.","Rerun `php artisan ide-helper:meta` and confirm the warning is gone and the meta file contains the expectedArguments entries."],"exampleFix":"# before\n$ php artisan ide-helper:meta\nCannot load template for routes: The file \"/app/vendor/barryvdh/laravel-ide-helper/php-templates/routes.php\" does not exist\n\n# after: restore the pruned vendor files\n$ composer reinstall barryvdh/laravel-ide-helper\n$ php artisan ide-helper:meta\nA new meta file was written to .phpstorm.meta.php","handlingStrategy":"fallback","validationCode":"// Verify the shipped templates exist before generating meta\n$tplDir = dirname(\\Composer\\InstalledVersions::getInstallPath('barryvdh/laravel-ide-helper')) . '/laravel-ide-helper/php-templates';\nforeach (['auth', 'configs', 'middleware', 'routes', 'views', 'translations'] as $name) {\n    if (!is_file(\"{$tplDir}/{$name}.php\")) {\n        fwrite(STDERR, \"Missing ide-helper template: {$name}\\n\");\n        exit(1);\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Do not prune or hand-copy vendor/ in Docker images; build images with composer and prune with explicit package lists only.","After interrupted composer operations, run `composer install` again or `composer reinstall barryvdh/laravel-ide-helper` instead of patching files.","Watch ide-helper:meta output for 'Cannot load template' warnings in CI and fail the build so degraded meta files are caught early."],"tags":["php","laravel","ide-helper","file-not-found","templates","phpstorm-meta"],"backgroundTag":"file-not-found","analyzedSha":"3a886dca5c7ec4854b316b1ac3bcdf9c43c1760b","analyzedAt":"2026-08-23T00:48:42.471Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}