MIME type detector for partial file streams of unlimited length
file-detector is a library for PHP 7.0+ that accepts a file stream of any length, even if it's a partial file type, and provides a MIME detector for it.
The detector class can be used with any framework and has no dependencies. This library may be installed via composer with the following command:
composer require ancarda/file-detector
The detector can then be initalized and used, like so. For example:
<?php
$resource = fopen('example.jpg', 'r');
$detector = new \Ancarda\File\Detector;
$mimetype = $detector->determineMimeType($resource);
//$mimetype is now 'image/jpg'