decodelabs/typify

Mime type detection tools

v0.4.0 2025-08-21 22:06 UTC

README

PHP from Packagist Latest Version Total Downloads GitHub Workflow Status PHPStan License

Mime type detection tools for PHP

Use typify to identify and apply mime types information to your files and responses.

Installation

composer require decodelabs/typify

Usage

Detecting types

Detect a mime type for a file path:

use DecodeLabs\Typify\Detector;

$detector = new Detector();
echo $detector->detect(__FILE__);
// application/x-php

Get known extensions for a type:

$exts = $detector->getExtensionsFor('text/plain');
// txt, text, conf, def, list, log, in

Suggest an extension for a mime type:

echo $detector->getExtensionFor('text/plain');
// txt

Licensing

Typify is licensed under the MIT License. See LICENSE for the full license text.