pekkis / mime-types
Mime type library
Installs: 127 631
Dependents: 5
Suggesters: 0
Security: 0
Stars: 2
Watchers: 3
Forks: 0
Open Issues: 0
Requires
- php: >=7.1.0
- dflydev/apache-mime-types: ~1.0
Requires (Dev)
- phpunit/phpunit: ~7.3
- symfony/http-foundation: ~3.4|~4.0
Suggests
- symfony/http-foundation: For symfony mime type resolver support
This package is not auto-updated.
Last update: 2024-12-21 19:11:04 UTC
README
A library for handling mime types
Use cases
- Resolve a file's mime type (via different strategies if necessary)
- Resolve a file extension's mime type
- Resolve a mime type's file extension(s) and override if needed.
Quickstart
<?php use Pekkis\MimeTypes\MimeTypes; $mt = new MimeTypes(); // Resolve mime type $mimeType = $mt->resolveMimeType($pathToFile); // Extension to mime type $mimeType = $mt->extensionToMimeType($extension); // Mime type to extension $extension = $mt->mimeTypeToExtension('image/jpeg'); // Don't like .jpeg extension? override it. $mt->override('jpeg', 'jpg');