PHPackages                             ctebah/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. [Mail &amp; Notifications](/categories/mail)
4. /
5. ctebah/mimey

ActiveLibrary[Mail &amp; Notifications](/categories/mail)

ctebah/mimey
============

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

v2.1.1(3mo ago)0171MITPHPPHP ^5.4|^7.0|^8.0

Since Apr 13Pushed 3mo agoCompare

[ Source](https://github.com/ctebah/mimey)[ Packagist](https://packagist.org/packages/ctebah/mimey)[ Docs](https://github.com/ctebah/mimey)[ RSS](/packages/ctebah-mimey/feed)WikiDiscussions master Synced 1w ago

READMEChangelogDependencies (2)Versions (3)Used By (1)

ctebah/mimey (Mimey)
====================

[](#ctebahmimey-mimey)

PHP library for converting file extensions to MIME types and vice versa. Installable as **`ctebah/mimey`** on [Packagist](https://packagist.org/packages/ctebah/mimey).

**Repository:** [github.com/ctebah/mimey](https://github.com/ctebah/mimey) — public; clone `https://github.com/ctebah/mimey.git` or `git@github.com:ctebah/mimey.git` (matches `origin`).

[![Latest Stable Version](https://camo.githubusercontent.com/44f3ecc953c29bb1809a58c74ddebd8b1bb6d9ea728b9c0a0a3085f7ca4a832b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6374656261682f6d696d65792e737667)](https://packagist.org/packages/ctebah/mimey)[![License](https://camo.githubusercontent.com/9405977c9ae9547da46015f10ee8e46f52747ef1ec6054ce79751830d15b87de/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6374656261682f6d696d65792e737667)](https://packagist.org/packages/ctebah/mimey)

This package is a maintained fork of **[`ralouphie/mimey`](https://packagist.org/packages/ralouphie/mimey)** (same MIT license and original copyright; see [`license`](license)). Upstream mapping logic and API are preserved; the **`ctebah/mimey`** package exists so dependents (for example **UFW**) can require it from Packagist without a custom Composer `repositories` entry.

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`.

Install
-------

[](#install)

Requires PHP **&gt;= 5.4** (see `composer.json`).

```
composer require ctebah/mimey
```

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());
```

###  Health Score

37

—

LowBetter than 81% of packages

Maintenance81

Actively maintained with recent releases

Popularity6

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity40

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 80% 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

102d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/454488?v=4)[Stevan Koprivica](/maintainers/ctebah)[@ctebah](https://github.com/ctebah)

---

Top Contributors

[![ralouphie](https://avatars.githubusercontent.com/u/1500005?v=4)](https://github.com/ralouphie "ralouphie (36 commits)")[![ctebah](https://avatars.githubusercontent.com/u/454488?v=4)](https://github.com/ctebah "ctebah (3 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)")[![coopers98](https://avatars.githubusercontent.com/u/116313?v=4)](https://github.com/coopers98 "coopers98 (1 commits)")

---

Tags

mimemime-typefile extensionapachemimetypes

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[symfony/mime

Allows manipulating MIME messages

2.8k716.9M1.4k](/packages/symfony-mime)[dflydev/apache-mime-types

Apache MIME Types

772.0M37](/packages/dflydev-apache-mime-types)[zbateson/mail-mime-parser

MIME email message parser

54953.3M95](/packages/zbateson-mail-mime-parser)[php-mime-mail-parser/php-mime-mail-parser

A fully tested email parser for PHP 8.2+ (mailparse extension wrapper).

1.0k10.4M37](/packages/php-mime-mail-parser-php-mime-mail-parser)[fileeye/mimemap

A PHP library to handle MIME Content-Type fields and their related file extensions.

269.9M19](/packages/fileeye-mimemap)[zbateson/stream-decorators

PHP psr7 stream decorators for mime message part streams

4752.6M9](/packages/zbateson-stream-decorators)

PHPackages © 2026

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