This package is abandoned and no longer maintained. No replacement package was suggested.

PHP MIME Types Guesser and extension mapping.

Fund package maintenance!

1.6.0 2020-01-06 20:43 UTC


PHP MIME Types Guesser and extension mapper.

68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6e6172726f77737061726b2f6d696d6574797065732e7376673f7374796c653d666c61742d737175617265 68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253545372e322e302d3838393242462e7376673f7374796c653d666c61742d737175617265 68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f727573742d6c616e672f727573742f6d61737465722e7376673f7374796c653d666c61742d737175617265 68747470733a2f2f696d672e736869656c64732e696f2f636f6465636f762f632f6769746875622f6e6172726f77737061726b2f6d696d6574797065732f6d61737465722e7376673f7374796c653d666c61742d737175617265 68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265

built with jshttp/mime-db.

Mime types mapping, the right way.

This library uses jshttp/mime-db as its default mapping which aggregates data from multiple sources and creates a single db.json making it the most complete mapping.


composer require narrowspark/mimetypes


This mime type guesser has support for all OS supported guesser.

    use Narrowspark\MimeType\MimeType;
    // You can register custom guessers by calling the register() method

    return MimeType::guess('image.gif'); // returns image/gif

You looking for the full mime type array? Just use:

    use Narrowspark\MimeType\MimeTypesList;

    return MimeTypesList::MIMES; // returns array

If you like to use the build in php mime type guesser, just use:

    use Narrowspark\MimeType\MimeTypeFileInfoGuesser;
    use Narrowspark\MimeType\MimeTypeFileBinaryGuesser;
    use Narrowspark\MimeType\MimeTypeExtensionGuesser;
    use Narrowspark\MimeType\MimeTypeFileExtensionGuesser;

    // Inspecting the file using finfo and relies on magic db files.
    return MimeTypeFileInfoGuesser::guess('image.gif'); // returns image/gif
    // Inspecting the file using file -b --mime
    return MimeTypeFileBinaryGuesser::guess('image.gif'); // returns image/gif
    // Inspecting the extension using mime type list
    return MimeTypeExtensionGuesser::guess('gif'); // returns image/gif
    // Inspecting the file using mime type list
    return MimeTypeFileExtensionGuesser::guess('image.gif'); // returns image/gif


If you would like to help take a look at the list of issues and check our Contributing guild.

Note: Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.


The Narrowspark mimetypes is open-sourced software licensed under the MIT license