Skip to content

Commit

Permalink
minor #35808 [HttpFoundation] Fixed Mime dependency missing error (He…
Browse files Browse the repository at this point in the history
…ahDude)

This PR was merged into the 5.1-dev branch.

Discussion
----------

[HttpFoundation] Fixed Mime dependency missing error

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | kinda
| New feature?  | no
| Deprecations? | no
| Tickets       | ~
| License       | MIT
| Doc PR        | ~

Follows #35642, by adding a missing exception and a note in the UPGRADE file (CHANGELOG in HttpFoundation was already up to date).
Reported in symfony/symfony-docs#1307

Commits
-------

fef0de3 [HttpFoundation] Fixed Mimes dependency missing error
  • Loading branch information
nicolas-grekas committed Feb 23, 2020
2 parents 269c4a2 + fef0de3 commit b3b368b
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
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
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 b3b368b

Please sign in to comment.