1. Go to this page and download the library: Download esi/mimey library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
esi / mimey example snippets
$mimes = new MimeTypes;
// Convert extension to MIME type:
$mimes->getMimeType('json'); // application/json
// Convert MIME type to extension:
$mimes->getExtension('application/json'); // json
$json = MimeType::ApplicationJson;
echo $json->getExtension(); // json
echo $json->value; // application/json
$html = MimeType::fromExtension('html');
echo $html->value; // text/html
MimeType::fromExtension('asdf'); // throws an InvalidArgumentException if the extension cannot be found
// Get all MIME types for an extension:
$mimes->getAllMimeTypes('wmz'); // array('application/x-ms-wmz', 'application/x-msmetafile')
// Get all extensions for a MIME type:
$mimes->getAllExtensions('image/jpeg'); // array('jpeg', 'jpg', 'jpe')
use Esi\Mimey\Mapping\Builder;
// Create a builder using the built-in conversions as the basis.
$builder = Builder::create();
// Add a conversion. This conversion will take precedence over existing ones.
$builder->add('custom/mime-type', 'myextension');
$mimes = new MimeTypes($builder->getMapping());
$mimes->getMimeType('myextension'); // custom/mime-type
$mimes->getExtension('custom/mime-type'); // myextension
// Add a bunch of custom conversions.
$builder->add(...);
$builder->add(...);
$builder->add(...);
...
// Save the conversions to a cached file.
$builder->save($cacheFilePath);
// Load the conversions from a cached file.
$builder = Builder::load($cacheFilePath);
$mimes = new MimeTypes($builder->getMapping());
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.