use Illuminate\Http\File; use Illuminate\Support\Facades\Storage; use Mimey\MimeTypes; $filePath = Storage::path('example.png'); $file = new File($filePath); $mime = (new MimeTypes)->getMimeType($file->getExtension()); echo $mime; // Output: image/png
use Mimey\MimeTypes; $mimeTypes = (new MimeTypes)->getAll(); print_r($mimeTypes); // Output: Array ( [123] => application/vnd.lotus-1-2-3 [3dml] => text/vnd.in3d.3dml ... )In this example, we're using PHP File mime's `getAll` method to get a list of all supported mime types. The method returns an associative array where the key is the file extension and the value is the corresponding mime type. Overall, PHP File mime is a useful library for detecting file mime types in PHP applications. It is part of the Laravel framework and can be used in non-Laravel projects as well.