pekkis/mime-types

Mime type library

v2.0.0 2018-08-17 11:06 UTC

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');