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

Abandoned → [league/mime-type-detection](/?search=league%2Fmime-type-detection)ArchivedLibrary

mzur/guess-mime
===============

Guess the MIME type from the file extension (Linux only).

v1.0(4y ago)0441MITPHP

Since Aug 3Pushed 4y ago1 watchersCompare

[ Source](https://github.com/mzur/guess-mime)[ Packagist](https://packagist.org/packages/mzur/guess-mime)[ RSS](/packages/mzur-guess-mime/feed)WikiDiscussions main Synced 2d ago

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

Guess MIME
==========

[](#guess-mime)

[![Tests](https://github.com/mzur/guess-mime/actions/workflows/php.yml/badge.svg)](https://github.com/mzur/guess-mime/actions/workflows/php.yml)

**Abandoned:** Use [`league/mime-type-detection`](https://github.com/thephpleague/mime-type-detection) instead.

Guess the MIME type from the file extension (Linux only). This can be handy if the file does not exist or cannot be accessed.

**Warning:** This package should not be used if the file actually exists and can be accessed (e.g. to check user-uploaded files). Use [`finfo_file`](https://www.php.net/manual/en/function.finfo-file.php) for that.

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

[](#installation)

```
composer require mzur/guess-mime

```

By default this package requires the `/etc/mime.types` file to be present. It can be installed e.g. with the `mime-support` package (Ubuntu) or the `mailcap` package (Alpine). A different file can be configured, too (see below).

Usage
-----

[](#usage)

```
use Mzur\GuessMIME\GuessMIME;

$gm = new GuessMIME;
$mime = $gm->guess('image.jpg');
var_dump($mime); // image/jpeg
```

If a MIME type cannot be guessed, `application/octet-stream` is returned. You can also limit the available MIME types, use a different MIME type database file (default: `/etc/mime.types`) and use a strict check that returns `null` if the MIME type cannot be guessed:

```
use Mzur\GuessMIME\GuessMIME;

// Limit detection to image/jpeg and use a different database file.
$gm = new GuessMIME(['image/jpeg'], '/home/user/.mime.types');

// Default MIME type.
$mime = $gm->guess('image.png');
var_dump($mime); // application/octet-stream

// Use strict check.
$mime = $gm->guess('image.png', true);
var_dump($mime); // null
```

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 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

Unknown

Total

1

Last Release

1743d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/2457311?v=4)[Martin Zurowietz](/maintainers/mzur)[@mzur](https://github.com/mzur)

---

Top Contributors

[![mzur](https://avatars.githubusercontent.com/u/2457311?v=4)](https://github.com/mzur "mzur (5 commits)")

---

Tags

mime-typesphpphp-library

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

PHPackages © 2026

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