Php Mime Type Save Abandoned

A comprehensive MIME-types lib for PHP

Project README

xobotyi/php-mime-type

A comprehensive MIME-type lib allowing you to get known file extensions by mime-type and vice-versa.
It uses mime-db underneath as it is most thorough and recent mime-types list, aggregated from IANA, Apache and nginx

Install

composer require xobotyi/php-mime-type

Usage

<?php

use xobotyi\MimeType;

MimeType::getExtensions('text/plain'); // ['txt', 'text', 'conf', 'def', 'list', 'log', 'in', 'ini']
MimeType::getExtensionMimes('wav'); // ['audio/wav', 'audio/wave', 'audio/x-wav']

API

MimeType::isSupported(string $type)

Description: Check whether mime-type is supported.
Parameters: $type - mime-type to check.
Return: boolean

MimeType::getExtensions(string $mime)

Description: Return the mime-type's associated extensions.
Return: plain array of strings or null if mime-type is unknown

MimeType::getSupportedMimes(string $group = null)

Description: Return the plain list of supported mime-types.
Parameters: $group - group of mime-types to return (group is string before the slash, 4ex: text, video).
Return: plain array of strings.

MimeType::isSupportedExtension(string $extension)

Description: Check whether file extension is supported.
Parameters: $extension - extension to check (without leading dot).
Return: bool

MimeType::getExtensionMimes()

Description: Return known relative mime-types
Return: Array (null if extension is unknown), even for extensions that associated with a single mime-type.
This is made for return values monotony, due to some extensions are associated with more than one mime-type.

MimeType::getSupportedExtensions()

Description: Return the plain list of supported file extensions.
Return: plain array of strings or numbers (some file extensions are numbers only so the treated as integer)

Open Source Agenda is not affiliated with "Php Mime Type" Project. README Source: xobotyi/php-mime-type
Stars
31
Open Issues
0
Last Commit
3 years ago
License
MIT

Open Source Agenda Badge

Open Source Agenda Rating