decodelabs/typify

Mime type detection tools

v0.2.4 2023-09-26 11:35 UTC

This package is auto-updated.

Last update: 2024-04-06 23:43:30 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.

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.