decodelabs / typify
Mime type detection tools
Installs: 1 014
Dependents: 0
Suggesters: 0
Security: 0
Stars: 6
Watchers: 3
Forks: 0
Open Issues: 0
Requires
- php: ^8.1
- decodelabs/exceptional: ^0.4
- decodelabs/veneer: ^0.11.6
Requires (Dev)
- decodelabs/clip: ^0.3.15
- decodelabs/phpstan-decodelabs: ^0.6
README
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.