8000 minor #35808 [HttpFoundation] Fixed Mime dependency missing error (He… · symfony/symfony@b3b368b · GitHub
[go: up one dir, main page]

Skip to content

Commit b3b368b

Browse files
minor #35808 [HttpFoundation] Fixed Mime dependency missing error (HeahDude)
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
2 parents 269c4a2 + fef0de3 commit b3b368b

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

UPGRADE-5.1.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ HttpFoundation
3636
* Deprecate `Response::create()`, `JsonResponse::create()`,
3737
`RedirectResponse::create()`, and `StreamedResponse::create()` methods (use
3838
`__construct()` instead)
39+
* Made the Mime component an optional dependency
3940

4041
Messenger
4142
---------

src/Symfony/Component/HttpFoundation/File/File.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,10 @@ public function guessExtension()
7474
*/
7575
public function getMimeType()
7676
{
77+
if (!class_exists(MimeTypes::class)) {
78+
throw new \LogicException('You cannot guess the mime type as the Mime component is not installed. Try running "composer require symfony/mime".');
79+
}
80+
7781
return MimeTypes::getDefault()->guessMimeType($this->getPathname());
7882
}
7983

0 commit comments

Comments
 (0)
0