laravel/framework · error · FileNotFoundException

File does not exist at path {$path}.

Error message

File does not exist at path {$path}.

What it means

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().

Source

Thrown at src/Illuminate/Filesystem/Filesystem.php:58

        return ! $this->exists($path);
    }

    /**
     * Get the contents of a file.
     *
     * @param  string  $path
     * @param  bool  $lock
     * @return string
     *
     * @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
     */
    public function get($path, $lock = false)
    {
        if ($this->isFile($path)) {
            return $lock ? $this->sharedGet($path) : file_get_contents($path);
        }

        throw new FileNotFoundException("File does not exist at path {$path}.");
    }

    /**
     * Get the contents of a file as decoded JSON.
     *
     * @param  string  $path
     * @param  int  $flags
     * @param  bool  $lock
     * @return array
     *
     * @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
     */
    public function json($path, $flags = 0, $lock = false)
    {
        return json_decode($this->get($path, $lock), true, 512, $flags);
    }

    /**

View on GitHub (pinned to bd6b5437e6)

Solutions

  1. Guard the call: if (File::exists($path)) { File::get($path); }.
  2. Verify the path is absolute or resolved against the correct base (base_path(), storage_path()).
  3. Ensure the file is committed or generated by a build step (e.g. composer, artisan cache).
  4. Fix filesystem permissions so is_file returns true for readable regular files.

Example fix

// before
$contents = File::get(storage_path('app/manifest.json'));

// after
$path = storage_path('app/manifest.json');
abort_unless(File::exists($path), 404);
$contents = File::get($path);
Defensive patterns

Strategy: type-guard

Validate before calling

$path = storage_path('app/' . $relative);
if (! \Illuminate\Filesystem\Filesystem::isFile($path)) {
    abort(404, "File not found: {$relative}");
}
return \File::get($path);

Type guard

function readableFile(string $path): bool
{
    return is_file($path) && is_readable($path);
}

Try / catch

use Illuminate\Contracts\Filesystem\FileNotFoundException;
try {
    $contents = File::get($path);
} catch (FileNotFoundException $e) {
    abort(404, $e->getMessage());
}

Prevention

When it happens

Trigger: 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.

Common situations: 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().

Related errors


AI-assisted analysis of laravel/framework@bd6b5437e6 (2026-08-06). Data as JSON: /data/errors/2102d86a0727aa68.json. Report an issue: GitHub.