-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
Closed
Description
Symfony version(s) affected
v6.3.0
Description
The mime type map included in \Symfony\Component\Mime\MimeTypes
is missing text/x-php
, which is associated with PHP files, which prevents the MimeTypes::getDefault()->getExtensions()
method from returning the valid extension for these files.
How to reproduce
- Create a simple PHP file:
$ cat phpinfo.php <?php phpinfo();
- Confirm the filesystem can identify the mimetype:
$ file -b --mime -- phpinfo.php text/x-php; charset=us-ascii
- Detect the mime and try to retrieve the extension with Symfony:
use \Symfony\Component\Mime\MimeTypes; $mime = MimeTypes::getDefault()->guessMimeType('phpinfo.php'); echo "Mime => {$mime}".PHP_EOL; $extensions = MimeTypes::getDefault()->getExtensions($mime); echo "Extensions => ".implode(', ', $extensions);
Mime => text/x-php Extensions =>
Possible Solution
The mapping of text/x-php => .php
should be added to allow for proper detection of these files.
Additional Context
The Resources/bin/update_mime_types.php
file suggests this might be a problem upstream, or something that can be hardcoded within that script? I'm not familiar with the mechanics of the mime type mapping, so I thought it best to report the issue directly here and seek further instructions. Please let me know if I need to report the issue elsewhere.
angelej