Skip to content

decodelabs/typify

Repository files navigation

Typify

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.

Get news and updates on the DecodeLabs blog.


Installation

composer require decodelabs/typify

Usage

Importing

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.

Detecting types

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

Licensing

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