Skip to content

Commit

Permalink
[HttpFoundation] Fixed Mimes dependency missing error
Browse files Browse the repository at this point in the history
  • Loading branch information
HeahDude committed Feb 20, 2020
1 parent f46ab58 commit fef0de3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions UPGRADE-5.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
---------
Expand Down
4 changes: 4 additions & 0 deletions src/Symfony/Component/HttpFoundation/File/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}

Expand Down

0 comments on commit fef0de3

Please sign in to comment.