From fef0de3eb63c783cdde789901e8ca5d27134c75c Mon Sep 17 00:00:00 2001 From: Jules Pietri Date: Thu, 20 Feb 2020 20:50:53 +0100 Subject: [PATCH] [HttpFoundation] Fixed Mimes dependency missing error --- UPGRADE-5.1.md | 1 + src/Symfony/Component/HttpFoundation/File/File.php | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/UPGRADE-5.1.md b/UPGRADE-5.1.md index 1fa3c6cf45c4..656f0b5d5dda 100644 --- a/UPGRADE-5.1.md +++ b/UPGRADE-5.1.md @@ -36,6 +36,7 @@ HttpFoundation * Deprecate `Response::create()`, `JsonResponse::create()`, `RedirectResponse::create()`, and `StreamedResponse::create()` methods (use `__construct()` instead) + * Made the Mime component an optional dependency Messenger --------- diff --git a/src/Symfony/Component/HttpFoundation/File/File.php b/src/Symfony/Component/HttpFoundation/File/File.php index 45f344e37531..e4df5f4df025 100644 --- a/src/Symfony/Component/HttpFoundation/File/File.php +++ b/src/Symfony/Component/HttpFoundation/File/File.php @@ -74,6 +74,10 @@ public function guessExtension() */ public function getMimeType() { + if (!class_exists(MimeTypes::class)) { + throw new \LogicException('You cannot guess the mime type as the Mime component is not installed. Try running "composer require symfony/mime".'); + } + return MimeTypes::getDefault()->guessMimeType($this->getPathname()); }