PHPackages                             xdg/mime - 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. xdg/mime

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

xdg/mime
========

PHP implementation of the Freedesktop Shared MIME-info Database standard.

1.0.4(2y ago)1711[1 PRs](https://github.com/php-xdg/mime/pulls)1MITPHPPHP &gt;=8.1

Since Jun 26Pushed 1y ago1 watchersCompare

[ Source](https://github.com/php-xdg/mime)[ Packagist](https://packagist.org/packages/xdg/mime)[ RSS](/packages/xdg-mime/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (4)Versions (16)Used By (1)

xdg/mime
========

[](#xdgmime)

[![codecov](https://camo.githubusercontent.com/17ff313945a3a55bd4b4092c8c6288a85ac361aa293173cd9ae7ccae14eb1d2d/68747470733a2f2f636f6465636f762e696f2f67682f7068702d7864672f6d696d652f6272616e63682f6d61696e2f67726170682f62616467652e7376673f746f6b656e3d45475a556a6349707545)](https://codecov.io/gh/php-xdg/mime)

This package is a pure PHP implementation of the [XDG Shared MIME-Info Database](http://standards.freedesktop.org/shared-mime-info-spec/) specification.

It is primarily aimed at MIME-type detection.

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

[](#installation)

```
$ composer require xdg/mime
```

Usage
-----

[](#usage)

- [Basic usage instructions](docs/basic_usage.md)
- [Customizing the MIME database](docs/customization.md)

Implementation notes
--------------------

[](#implementation-notes)

Most XDG Shared MIME-Info implementations read their data from binary cache files generated by the `update-mime-database` program. This turns out to be impractical in the context of PHP for several reasons:

- First, PHP doesn't have native `mmap` functionality, so reading these files at runtime can produce a lot of I/O.
- Second, parsing these files at runtime has a non-negligible overhead.
- And last, PHP runs on server environments where the `update-mime-database` program is often not available (and possibly even not installable).

Therefore, this library takes another approach: parsing the MIME database in its original XML format, and compiling it to executable PHP code. This yields several advantages:

- Since most PHP applications have a build / deploy step, the overhead of parsing the database at runtime is eliminated entirely.
- Generating PHP code allows leveraging the PHP opcode cache, which makes loading the database very fast.
- Since performance is less paramount at build time, the library does additional work to optimize the generated PHP code for optimal runtime performance.

For convenience, this package ships with a pre-compiled database, built from the [latest shared-mime-info database](https://gitlab.freedesktop.org/xdg/shared-mime-info/-/blob/master/data/freedesktop.org.xml.in).

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance27

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 98.6% 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 ~50 days

Recently: every ~107 days

Total

14

Last Release

770d ago

Major Versions

0.5 → 1.02023-02-03

### Community

Maintainers

![](https://www.gravatar.com/avatar/db8c537fa479fd389b9ef832345ebf665f767e3ff7c7c345bc0ba4c52b46a22f?d=identicon)[ju1ius](/maintainers/ju1ius)

---

Top Contributors

[![ju1ius](https://avatars.githubusercontent.com/u/218404?v=4)](https://github.com/ju1ius "ju1ius (144 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (2 commits)")

---

Tags

freedesktopguessermimemime-typemimetypexdgmimemime-typeguesserfreedesktopxdg

### Embed Badge

![Health badge](/badges/xdg-mime/health.svg)

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

###  Alternatives

[symfony/mime

Allows manipulating MIME messages

2.8k668.8M911](/packages/symfony-mime)[zbateson/mail-mime-parser

MIME email message parser

53949.2M79](/packages/zbateson-mail-mime-parser)[php-mime-mail-parser/php-mime-mail-parser

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

9979.6M27](/packages/php-mime-mail-parser-php-mime-mail-parser)[nette/mail

📧 Nette Mail: A handy library for creating and sending emails in PHP.

5389.8M246](/packages/nette-mail)[fileeye/mimemap

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

259.2M9](/packages/fileeye-mimemap)[zbateson/stream-decorators

PHP psr7 stream decorators for mime message part streams

4748.6M6](/packages/zbateson-stream-decorators)

PHPackages © 2026

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