{"record":{"id":"c26c28e09bcd88ea","repo":"laravel/framework","slug":"to-enable-support-for-guessing-extensions-please","errorCode":null,"errorMessage":"To enable support for guessing extensions, please install the symfony/mime package.","messagePattern":"To enable support for guessing extensions, please install the symfony/mime package\\.","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"src/Illuminate/Filesystem/Filesystem.php","lineNumber":444,"sourceCode":"     * @return string\n     */\n    public function extension($path)\n    {\n        return pathinfo($path, PATHINFO_EXTENSION);\n    }\n\n    /**\n     * Guess the file extension from the MIME type of a given file.\n     *\n     * @param  string  $path\n     * @return string|null\n     *\n     * @throws \\RuntimeException\n     */\n    public function guessExtension($path)\n    {\n        if (! class_exists(MimeTypes::class)) {\n            throw new RuntimeException(\n                'To enable support for guessing extensions, please install the symfony/mime package.'\n            );\n        }\n\n        return (new MimeTypes)->getExtensions($this->mimeType($path))[0] ?? null;\n    }\n\n    /**\n     * Get the file type of a given file.\n     *\n     * @param  string  $path\n     * @return string|false\n     */\n    public function type($path)\n    {\n        return filetype($path);\n    }\n","sourceCodeStart":426,"sourceCodeEnd":462,"githubUrl":"https://github.com/laravel/framework/blob/e0f6eb3518ac29fbbca8529e97d0df7fc9f24481/src/Illuminate/Filesystem/Filesystem.php#L426-L462","documentation":"Thrown by Filesystem::guessExtension() when Symfony\\Component\\Mime\\MimeTypes is not autoloadable. guessExtension() infers a file extension from MIME type by delegating to symfony/mime; without the package the lookup cannot run. Laravel refuses to fall back to a naive guess because that would produce misleading extensions.","triggerScenarios":"Calling File::guessExtension($path) (often indirectly via upload validation or UploadedFile handling) when symfony/mime is not installed.","commonSituations":"Custom minimal Laravel install that excluded symfony/mime; production build step that stripped suggested packages; framework upgrade where symfony/mime moved from required to suggested.","solutions":["Run composer require symfony/mime.","If extension guessing is optional, fall back to pathinfo($path, PATHINFO_EXTENSION) when the package is absent.","Verify presence in CI: composer show symfony/mime.","Pin the version compatible with your laravel/framework constraint."],"exampleFix":"// before\n$ext = File::guessExtension($path);\n\n// after (terminal)\n// composer require symfony/mime\n$ext = File::guessExtension($path);","handlingStrategy":"validation","validationCode":"if (! class_exists(\\Symfony\\Component\\Mime\\MimeTypes::class)) {\n    throw new RuntimeException('Run: composer require symfony/mime');\n}\nreturn File::guessExtension($path);","typeGuard":"function supportsGuessExtension(): bool {\n    return class_exists(\\Symfony\\Component\\Mime\\MimeTypes::class);\n}","tryCatchPattern":"try {\n    $ext = File::guessExtension($path);\n} catch (\\RuntimeException $e) {\n    $ext = pathinfo($path, PATHINFO_EXTENSION) ?: null;\n}","preventionTips":["Require symfony/mime for upload validation.","Fall back to pathinfo() when guessing is unavailable.","Verify presence of symfony/mime in CI.","Pin compatible versions in composer.json."],"tags":["filesystem","mime","symfony","dependency","uploads"],"backgroundTag":null,"analyzedSha":"e0f6eb3518ac29fbbca8529e97d0df7fc9f24481","analyzedAt":"2026-08-11T20:52:37.562Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}