PHPackages                             rwal127/mimey - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. rwal127/mimey

ActiveLibrary

rwal127/mimey
=============

PHP package for converting file extensions to MIME types and vice versa.

v1.0.0(9mo ago)02MITPHPPHP ^5.4|^7.0|^8.0

Since Jul 27Pushed 9mo agoCompare

[ Source](https://github.com/rwal127/mimey)[ Packagist](https://packagist.org/packages/rwal127/mimey)[ RSS](/packages/rwal127-mimey/feed)WikiDiscussions develop Synced 1mo ago

READMEChangelog (1)Dependencies (2)Versions (2)Used By (0)

Mime Types
==========

[](#mime-types)

Fork of PHP package for converting file extensions to MIME types and vice versa.

[![Build Status](https://camo.githubusercontent.com/0119d0367305fb27523813b0df64079603e223335e5c60d027ced4a66b9dc58b/68747470733a2f2f7472617669732d63692e6f72672f72616c6f75706869652f6d696d65792e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/ralouphie/mimey)[![Coverage Status](https://camo.githubusercontent.com/f0d4a5510667adc747cf2cf1c98d86d2752d26cb46ff2d69e7c3bb1e2a64543f/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f72616c6f75706869652f6d696d65792f62616467652e7376673f6272616e63683d6d617374657226736572766963653d676974687562)](https://coveralls.io/github/ralouphie/mimey?branch=master)[![Latest Stable Version](https://camo.githubusercontent.com/fbb935c8c4099c16f610dbf68939742d3c726d813dda41c6ed38fbda46f616af/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f72616c6f75706869652f6d696d65792e737667)](https://packagist.org/packages/ralouphie/mimey)[![Downloads per Month](https://camo.githubusercontent.com/d955defc3367ea745cb98ee1b61f03ee49fa6d7c9c532626d124d24389cbcd7d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646d2f72616c6f75706869652f6d696d65792e737667)](https://packagist.org/packages/ralouphie/mimey)[![License](https://camo.githubusercontent.com/b06def930e753f0a6696ffeec9a77492dd1c1c5b0a0105b42717f632de615486/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f72616c6f75706869652f6d696d65792e737667)](https://packagist.org/packages/ralouphie/mimey)

This package uses [httpd](https://httpd.apache.org/docs/current/programs/httpd.html)'s [mime.types](https://svn.apache.org/repos/asf/httpd/httpd/trunk/docs/conf/mime.types) to generate a mapping of file extension to MIME type and the other way around.

The `mime.types` file is parsed by `bin/generate.php` and converted into an optimized PHP array in `mime.types.php`which is then wrapped by helper class `\Mimey\MimeTypes`.

Usage
-----

[](#usage)

```
$mimes = new \Mimey\MimeTypes;

// Convert extension to MIME type:
$mimes->getMimeType('json'); // application/json

// Convert MIME type to extension:
$mimes->getExtension('application/json'); // json
```

### Getting All

[](#getting-all)

It's rare, but some extensions have multiple MIME types:

```
// Get all MIME types for an extension:
$mimes->getAllMimeTypes('wmz'); // array('application/x-ms-wmz', 'application/x-msmetafile')
```

However, there are many MIME types that have multiple extensions:

```
// Get all extensions for a MIME type:
$mimes->getAllExtensions('image/jpeg'); // array('jpeg', 'jpg', 'jpe')
```

### Custom Conversions

[](#custom-conversions)

You can add custom conversions by changing the mapping that is given to `MimeTypes`.

There is a `MimeMappingBuilder` that can help with this:

```
// Create a builder using the built-in conversions as the basis.
$builder = \Mimey\MimeMappingBuilder::create();

// Add a conversion. This conversion will take precedence over existing ones.
$builder->add('custom/mime-type', 'myextension');

$mimes = new \Mimey\MimeTypes($builder->getMapping());
$mimes->getMimeType('myextension'); // custom/mime-type
$mimes->getExtension('custom/mime-type'); // myextension
```

You can add as many conversions as you would like to the builder:

```
$builder->add('custom/mime-type', 'myextension');
$builder->add('foo/bar', 'foobar');
$builder->add('foo/bar', 'fbar');
$builder->add('baz/qux', 'qux');
$builder->add('cat/qux', 'qux');
...
```

#### Optimized Custom Conversion Loading

[](#optimized-custom-conversion-loading)

You can optimize the loading of custom conversions by saving all conversions to a compiled PHP file as part of a build step.

```
// Add a bunch of custom conversions.
$builder->add(...);
$builder->add(...);
$builder->add(...);
...
// Save the conversions to a cached file.
$builder->save($cache_file_path);
```

The file can then be loaded to avoid overhead of repeated `$builder->add(...)` calls:

```
// Load the conversions from a cached file.
$builder = \Mimey\MimeMappingBuilder::load($cache_file_path);
$mimes = new \Mimey\MimeTypes($builder->getMapping());
```

Install
-------

[](#install)

Compatible with PHP &gt;= 5.4.

```
composer require rwal127/mimey

```

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance57

Moderate activity, may be stable

Popularity2

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 83.7% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

286d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/6807237a0b4b3f5dcf3338f79a8de0a1b8c6ed5dc1065a88a06dc730123f924e?d=identicon)[sytrus](/maintainers/sytrus)

---

Top Contributors

[![ralouphie](https://avatars.githubusercontent.com/u/1500005?v=4)](https://github.com/ralouphie "ralouphie (36 commits)")[![coopers98](https://avatars.githubusercontent.com/u/116313?v=4)](https://github.com/coopers98 "coopers98 (1 commits)")[![dabyjones](https://avatars.githubusercontent.com/u/145117352?v=4)](https://github.com/dabyjones "dabyjones (1 commits)")[![danielindiano](https://avatars.githubusercontent.com/u/553232?v=4)](https://github.com/danielindiano "danielindiano (1 commits)")[![janakael89](https://avatars.githubusercontent.com/u/16027359?v=4)](https://github.com/janakael89 "janakael89 (1 commits)")[![peter279k](https://avatars.githubusercontent.com/u/9021747?v=4)](https://github.com/peter279k "peter279k (1 commits)")[![chriskonnertz](https://avatars.githubusercontent.com/u/4319323?v=4)](https://github.com/chriskonnertz "chriskonnertz (1 commits)")[![sik0r](https://avatars.githubusercontent.com/u/26262044?v=4)](https://github.com/sik0r "sik0r (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/rwal127-mimey/health.svg)

```
[![Health](https://phpackages.com/badges/rwal127-mimey/health.svg)](https://phpackages.com/packages/rwal127-mimey)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
