Use typify to identify and apply mime types information to your files and responses.
Get news and updates on the DecodeLabs blog.
composer require decodelabs/typify
Typify uses Veneer to provide a unified frontage under DecodeLabs\Typify
.
You can access all the primary functionality via this static frontage without compromising testing and dependency injection.
Detect a mime type for a file path:
use DecodeLabs\Typify;
echo Typify::detect(__FILE__);
// application/x-php
Get known extensions for a type:
use DecodeLabs\Typify;
$exts = Typify::getExtensionsFor('text/plain');
// txt, text, conf, def, list, log, in
Suggest an extension for a mime type:
use DecodeLabs\Typify;
echo Typify::getExtensionFor('text/plain');
// txt
Typify is licensed under the MIT License. See LICENSE for the full license text.