decodelabs / typify
Mime type detection tools
Installs: 1 229
Dependents: 1
Suggesters: 0
Security: 0
Stars: 6
Watchers: 2
Forks: 0
Open Issues: 0
Requires
- php: ^8.4
- decodelabs/exceptional: ^0.5
- decodelabs/veneer: ^0.12.1
Requires (Dev)
- decodelabs/clip: ^0.4
- decodelabs/phpstan-decodelabs: ^0.7
README
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
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.