{"id":"cf2dacfd64dd7edb","repo":"laravel/framework","slug":"this-driver-does-not-support-retrieving-urls","errorCode":null,"errorMessage":"This driver does not support retrieving URLs.","messagePattern":"This driver does not support retrieving URLs\\.","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"src/Illuminate/Filesystem/FilesystemAdapter.php","lineNumber":797,"sourceCode":"     */\n    public function url($path)\n    {\n        if (isset($this->config['prefix'])) {\n            $path = $this->concatPathToUrl($this->config['prefix'], $path);\n        }\n\n        $adapter = $this->adapter;\n\n        if (method_exists($adapter, 'getUrl')) {\n            return $adapter->getUrl($path);\n        } elseif (method_exists($this->driver, 'getUrl')) {\n            return $this->driver->getUrl($path);\n        } elseif ($adapter instanceof FtpAdapter || $adapter instanceof SftpAdapter) {\n            return $this->getFtpUrl($path);\n        } elseif ($adapter instanceof LocalAdapter) {\n            return $this->getLocalUrl($path);\n        } else {\n            throw new RuntimeException('This driver does not support retrieving URLs.');\n        }\n    }\n\n    /**\n     * Get the URL for the file at the given path.\n     *\n     * @param  string  $path\n     * @return string\n     */\n    protected function getFtpUrl($path)\n    {\n        return isset($this->config['url'])\n            ? $this->concatPathToUrl($this->config['url'], $path)\n            : $path;\n    }\n\n    /**\n     * Get the URL for the file at the given path.","sourceCodeStart":779,"sourceCodeEnd":815,"githubUrl":"https://github.com/laravel/framework/blob/bd6b5437e6ad87bb49f9b426724f07a9f64e9683/src/Illuminate/Filesystem/FilesystemAdapter.php#L779-L815","documentation":"Thrown by FilesystemAdapter::url() when the underlying Flysystem adapter is not one of the URL-capable types and exposes no getUrl() method. Laravel can synthesize URLs for Local, FTP, and SFTP adapters, and for adapters (like S3) that implement getUrl(); any other custom adapter has no URL semantics, so the call is rejected.","triggerScenarios":"Calling Storage::disk($name)->url($path) on a disk whose driver does not provide URLs - e.g. a memory adapter, a custom adapter without getUrl, or a generic Flysystem adapter not in the supported set.","commonSituations":"Calling url() on the default 'local' disk that lacks a 'url' config key in some setups; using a custom adapter registered via Storage::extend() that doesn't implement getUrl(); using an in-memory adapter in tests.","solutions":["Switch to a disk type that supports URLs (local with a url/serve config, s3, sftp, ftp).","For a custom adapter, implement a getUrl($path) method on the adapter.","Provide a 'url' config key so the local/ftp URL synthesis returns a value.","Set the temporaryUrlCallback if you need synthetic URLs for an unsupported adapter."],"exampleFix":"// before - custom adapter has no getUrl\n$url = Storage::disk('memory')->url('file.txt');\n\n// after - use a local disk with url config\n// config/filesystems.php: 'public' => ['driver'=>'local','root'=>storage_path('app/public'),'url'=>'/storage']\n$url = Storage::disk('public')->url('file.txt');","handlingStrategy":"validation","validationCode":"$adapter = Storage::disk($name)->getAdapter();\nif (! method_exists($adapter, 'getUrl')\n    && ! $adapter instanceof \\League\\Flysystem\\Local\\LocalFilesystemAdapter\n    && ! $adapter instanceof \\League\\Flysystem\\Ftp\\FtpAdapter\n    && ! $adapter instanceof \\League\\Flysystem\\PhpseclibV3\\SftpAdapter) {\n    throw new RuntimeException(\"Disk {$name} cannot generate URLs\");\n}","typeGuard":"function diskSupportsUrls(\\Illuminate\\Filesystem\\FilesystemAdapter $disk): bool\n{\n    $a = $disk->getAdapter();\n    return method_exists($a, 'getUrl')\n        || $a instanceof \\League\\Flysystem\\Local\\LocalFilesystemAdapter\n        || $a instanceof \\League\\Flysystem\\Ftp\\FtpAdapter\n        || $a instanceof \\League\\Flysystem\\PhpseclibV3\\SftpAdapter;\n}","tryCatchPattern":"try {\n    $url = Storage::disk($name)->url($path);\n} catch (\\RuntimeException $e) {\n    if (str_contains($e->getMessage(), 'does not support retrieving URLs')) {\n        $url = null; // handle gracefully\n    } else {\n        throw $e;\n    }\n}","preventionTips":["Only call url() on URL-capable disks (local with url config, s3, ftp, sftp).","Implement getUrl() on custom adapters.","Provide a 'url' key in disk config for local disks."],"tags":["filesystem","flysystem","url","adapter","configuration"],"analyzedSha":"bd6b5437e6ad87bb49f9b426724f07a9f64e9683","analyzedAt":"2026-08-06T00:28:32.783Z","schemaVersion":2}