{"id":"2102d86a0727aa68","repo":"laravel/framework","slug":"file-does-not-exist-at-path-path","errorCode":null,"errorMessage":"File does not exist at path {$path}.","messagePattern":"File does not exist at path (.+?)\\.","errorType":"exception","errorClass":"FileNotFoundException","httpStatus":null,"severity":"error","filePath":"src/Illuminate/Filesystem/Filesystem.php","lineNumber":58,"sourceCode":"        return ! $this->exists($path);\n    }\n\n    /**\n     * Get the contents of a file.\n     *\n     * @param  string  $path\n     * @param  bool  $lock\n     * @return string\n     *\n     * @throws \\Illuminate\\Contracts\\Filesystem\\FileNotFoundException\n     */\n    public function get($path, $lock = false)\n    {\n        if ($this->isFile($path)) {\n            return $lock ? $this->sharedGet($path) : file_get_contents($path);\n        }\n\n        throw new FileNotFoundException(\"File does not exist at path {$path}.\");\n    }\n\n    /**\n     * Get the contents of a file as decoded JSON.\n     *\n     * @param  string  $path\n     * @param  int  $flags\n     * @param  bool  $lock\n     * @return array\n     *\n     * @throws \\Illuminate\\Contracts\\Filesystem\\FileNotFoundException\n     */\n    public function json($path, $flags = 0, $lock = false)\n    {\n        return json_decode($this->get($path, $lock), true, 512, $flags);\n    }\n\n    /**","sourceCodeStart":40,"sourceCodeEnd":76,"githubUrl":"https://github.com/laravel/framework/blob/bd6b5437e6ad87bb49f9b426724f07a9f64e9683/src/Illuminate/Filesystem/Filesystem.php#L40-L76","documentation":"Thrown by Filesystem::get() when is_file($path) returns false. The method is the low-level reader for file contents and refuses to read directories, symlinks-to-nowhere, or missing paths rather than letting file_get_contents emit a PHP warning. It is the backing call for many helpers including json().","triggerScenarios":"Calling File::get($path) (or File::json($path), which delegates) where $path does not exist, is a directory, is a dangling symlink, or lacks read permission such that is_file is false.","commonSituations":"Reading config/cache files before they are generated; deployment where storage/ files are gitignored and missing on a fresh clone; wrong working directory giving a relative path that doesn't resolve; race where a file is deleted between an exists() check and get().","solutions":["Guard the call: if (File::exists($path)) { File::get($path); }.","Verify the path is absolute or resolved against the correct base (base_path(), storage_path()).","Ensure the file is committed or generated by a build step (e.g. composer, artisan cache).","Fix filesystem permissions so is_file returns true for readable regular files."],"exampleFix":"// before\n$contents = File::get(storage_path('app/manifest.json'));\n\n// after\n$path = storage_path('app/manifest.json');\nabort_unless(File::exists($path), 404);\n$contents = File::get($path);","handlingStrategy":"type-guard","validationCode":"$path = storage_path('app/' . $relative);\nif (! \\Illuminate\\Filesystem\\Filesystem::isFile($path)) {\n    abort(404, \"File not found: {$relative}\");\n}\nreturn \\File::get($path);","typeGuard":"function readableFile(string $path): bool\n{\n    return is_file($path) && is_readable($path);\n}","tryCatchPattern":"use Illuminate\\Contracts\\Filesystem\\FileNotFoundException;\ntry {\n    $contents = File::get($path);\n} catch (FileNotFoundException $e) {\n    abort(404, $e->getMessage());\n}","preventionTips":["Always check File::exists() or File::isFile() before get().","Prefer absolute paths from storage_path()/resource_path().","Generate placeholder files in deployment so expected paths always exist."],"tags":["filesystem","file-not-found","storage","io"],"analyzedSha":"bd6b5437e6ad87bb49f9b426724f07a9f64e9683","analyzedAt":"2026-08-06T00:28:32.783Z","schemaVersion":2}