PHPackages                             blobfolio/blob-mimes - 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. blobfolio/blob-mimes

AbandonedArchivedLibrary

blobfolio/blob-mimes
====================

A comprehensive MIME and file extension tool for PHP.

8.0.0(7y ago)125.8k1WTFPLPHPPHP &gt;= 7.0

Since Jan 15Pushed 6y ago4 watchersCompare

[ Source](https://github.com/Blobfolio/blob-mimes)[ Packagist](https://packagist.org/packages/blobfolio/blob-mimes)[ Docs](https://github.com/Blobfolio/blob-mimes)[ RSS](/packages/blobfolio-blob-mimes/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (10)Dependencies (2)Versions (14)Used By (0)

blob-mimes
==========

[](#blob-mimes)

**DEPRECATED**: This project is no longer actively maintained. Please see [Righteous MIMEs](https://github.com/Blobfolio/righteous-mimes) instead.

A comprehensive MIME and file extension tool for PHP. Finally!

Table of Contents
-----------------

[](#table-of-contents)

1. [Features](#features)
2. [Requirements](#requirements)
3. [Installation](#installation)
4. [Reference](#reference)
    - [check\_ext\_and\_mime()](#check_ext_and_mime)
    - [finfo()](#finfo)
    - [get\_extension()](#get_extension)
    - [get\_extensions()](#get_extensions)
    - [get\_mime()](#get_mime)
    - [get\_mimes()](#get_mimes)
5. [License](#license)

Features
--------

[](#features)

It should be simple, but MIME types and file extensions are wildly inconsistent. Attempting to derive and/or correct that information when, e.g. verifying a file upload, is a nightmare in any programming language.

blob-mimes is a PHP library with a comprehensive MIME/ext database and simple helpers to access that information in a variety of ways:

- Pull MIME information based on a file name or extension;
- Pull file extensions for a given MIME type;
- Pull MIME information from a local file and verify its extension matches the actual content;

The database is compiled from the following sources:

- [IANA](https://www.iana.org/assignments/media-types)
- [Apache](https://raw.githubusercontent.com/apache/httpd/trunk/docs/conf/mime.types)
- [Nginx](http://hg.nginx.org/nginx/raw-file/default/conf/mime.types)
- [freedesktop.org](https://cgit.freedesktop.org/xdg/shared-mime-info/plain/freedesktop.org.xml.in)
- [Apache Tika](https://raw.githubusercontent.com/apache/tika/master/tika-core/src/main/resources/org/apache/tika/mime/tika-mimetypes.xml)

Requirements
------------

[](#requirements)

blob-mimes requires PHP 7.0+ with the following modules:

- BCMath
- DOM
- Fileinfo
- Filter
- JSON
- MBString
- SimpleXML

UTF-8 is used for all string encoding. This could create conflicts on environments using something else.

The build script additionally requires cURL.

Installation
------------

[](#installation)

Install via Composer:

```
composer require "blobfolio/blob-mimes:dev-master"
```

Reference
---------

[](#reference)

### check\_ext\_and\_mime()

[](#check_ext_and_mime)

Verify that a file extension and MIME type belong together. Because technology is always evolving and the MIME standard is always changing, this will consider `some/thing` and `some/x-thing` equivalent.

#### Arguments

[](#arguments)

- (*string*) File extension
- (*string*) MIME type
- (*bool*) (*optional*) Soft pass. If `TRUE`, the check will return `TRUE` if it lacks information about either the extension or MIME type.

#### Returns

[](#returns)

Returns `TRUE` or `FALSE`.

#### Example

[](#example)

```
$foo = blobfolio\mimes\mimes::check_ext_and_mime('jpeg', 'image/jpeg'); //TRUE
$foo = blobfolio\mimes\mimes::check_ext_and_mime('jpeg', 'image/gif'); //FALSE
```

### finfo()

[](#finfo)

Pull path and type information for a file, using its name and/or content. If it is determined that the file is incorrectly named, alternative names with the correct file extension(s) are suggested.

#### Arguments

[](#arguments-1)

- (*string*) Path
- (*string*) (*optional*) Nice name. If provided, the nice name will be treated as the filename. This can be useful if passing a temporary upload, for example. Default: `NULL`

#### Returns

[](#returns-1)

Returns all file information that can be derived according to the format below.

#### Example

[](#example-1)

```
print_r(blobfolio\mimes\mimes::finfo('../wp/img/blobfolio.svg'));
/*
array(
    [dirname] => /var/www/blob-common/wp/img
    [basename] => blobfolio.svg
    [extension] => svg
    [filename] => blobfolio
    [path] => /var/www/blob-common/wp/img/blobfolio.svg
    [mime] => image/svg+xml
    [suggested_filename] => array()
)
*/
```

### get\_extension()

[](#get_extension)

Retrieve information about a file extension.

#### Arguments

[](#arguments-2)

- (*string*) File extension

#### Returns

[](#returns-2)

Returns the information or `FALSE`. Note: The first MIME entry will always be the official (or most conventional) media type.

```
print_r(blobfolio\mimes\mimes::get_extension('jpeg'));
/*
array(
    [ext] => jpeg
    [mime] => array(
        0 => image/jpeg
        1 => image/pjpeg
    )
)
*/
```

### get\_extensions()

[](#get_extensions)

Retrieve information about all known file extensions.

#### Arguments

[](#arguments-3)

N/A

#### Returns

[](#returns-3)

Returns a MIME database organized by extension.

### get\_mime()

[](#get_mime)

Retrieve information about a MIME type.

#### Arguments

[](#arguments-4)

- (*string*) MIME type

#### Returns

[](#returns-4)

Returns the information or `FALSE`.

#### Example

[](#example-2)

```
print_r(blobfolio\mimes\mimes::get_mime('image/jpeg'));
/*
array(
    [mime] => image/jpeg
    [ext] => array(
        0 => jpeg
        1 => jpg
        2 => jpe
    )
    [source] => array(
        0 => Apache
        1 => Nginx
        2 => freedesktop.org
    )
)
*/
```

### get\_mimes()

[](#get_mimes)

Retrieve information about all known MIME types.

#### Arguments

[](#arguments-5)

N/A

#### Returns

[](#returns-5)

Returns a MIME database organized by type. Note: The first extension should be the most common for the type.

License
-------

[](#license)

Copyright © 2018 [Blobfolio, LLC](https://blobfolio.com) &lt;&gt;

This work is free. You can redistribute it and/or modify it under the terms of the Do What The Fuck You Want To Public License, Version 2.

```
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004

Copyright (C) 2004 Sam Hocevar

Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.

DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION

0. You just DO WHAT THE FUCK YOU WANT TO.

```

### Donations

[](#donations)

   [![Bitcoin QR](https://camo.githubusercontent.com/02c1aab6dc8b7908cb540a77b3df80ff1781b137aa6e4de8e795aac613ffe124/68747470733a2f2f626c6f62666f6c696f2e636f6d2f77702d636f6e74656e742f7468656d65732f62332f7376672f6274632d6769746875622e737667)](https://camo.githubusercontent.com/02c1aab6dc8b7908cb540a77b3df80ff1781b137aa6e4de8e795aac613ffe124/68747470733a2f2f626c6f62666f6c696f2e636f6d2f77702d636f6e74656e742f7468656d65732f62332f7376672f6274632d6769746875622e737667) If you have found this work useful and would like to contribute financially, Bitcoin tips are always welcome!

**1Af56Nxauv8M1ChyQxtBe1yvdp2jtaB1GF**

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity25

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor1

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

Every ~43 days

Recently: every ~102 days

Total

13

Last Release

2885d ago

Major Versions

v0.5 → 1.0.02017-01-24

1.3.2 → 8.0.02018-06-17

PHP version history (2 changes)1.1.0PHP &gt;= 7.0

1.1.4PHP &gt;= 5.6

### Community

Maintainers

![](https://www.gravatar.com/avatar/74cb6ecb5887fa7b80c3aa263b6016e403989d28e93a35420536740599d6d909?d=identicon)[joshstoik1](/maintainers/joshstoik1)

---

Top Contributors

[![joshstoik1](https://avatars.githubusercontent.com/u/403248?v=4)](https://github.com/joshstoik1 "joshstoik1 (265 commits)")

---

Tags

file-type-detectionfile-validationmedia-typemime-typesphpfilesextensionssuffixmimes

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/blobfolio-blob-mimes/health.svg)

```
[![Health](https://phpackages.com/badges/blobfolio-blob-mimes/health.svg)](https://phpackages.com/packages/blobfolio-blob-mimes)
```

###  Alternatives

[league/flysystem

File storage abstraction for PHP

13.6k639.1M2.2k](/packages/league-flysystem)[gedmo/doctrine-extensions

Doctrine behavioral extensions

4.1k118.8M366](/packages/gedmo-doctrine-extensions)[league/flysystem-aws-s3-v3

AWS S3 filesystem adapter for Flysystem.

1.6k263.6M790](/packages/league-flysystem-aws-s3-v3)[stof/doctrine-extensions-bundle

Integration of the gedmo/doctrine-extensions with Symfony

1.9k85.3M381](/packages/stof-doctrine-extensions-bundle)[league/flysystem-local

Local filesystem adapter for Flysystem.

226231.8M39](/packages/league-flysystem-local)[mikehaertl/php-tmpfile

A convenience class for temporary files

9729.7M20](/packages/mikehaertl-php-tmpfile)

PHPackages © 2026

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