PHPackages                             flysystem/mime-type-detection - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. flysystem/mime-type-detection

Abandoned → [league/mime-type-detection](/?search=league%2Fmime-type-detection)ArchivedLibrary[Utility &amp; Helpers](/categories/utility)

flysystem/mime-type-detection
=============================

Mime-type detection for Flysystem

20PHP

Since Feb 25Pushed 6y agoCompare

[ Source](https://github.com/flysystemphp/mime-type-detection)[ Packagist](https://packagist.org/packages/flysystem/mime-type-detection)[ RSS](/packages/flysystem-mime-type-detection/feed)WikiDiscussions master Synced 4d ago

READMEChangelogDependenciesVersions (1)Used By (0)

Flysystem Mime Type Detection
-----------------------------

[](#flysystem-mime-type-detection)

[![Author](https://camo.githubusercontent.com/d7d52362024683450617985055436a3ef44d3c2209c7ace3efdbdcd91f8324e4/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f617574686f722d406672616e6b64656a6f6e67652d626c75652e737667)](https://twitter.com/frankdejonge)[![Source Code](https://camo.githubusercontent.com/10488efd5d9ec5f962f33193398560ead654b513074b32444ee79d1e58a4d036/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f736f757263652d666c7973797374656d2532466d696d652d2d747970652d2d646574656374696f6e2d626c75652e737667)](https://github.com/flysystemphp/mime-type-detection)[![Latest Version](https://camo.githubusercontent.com/8e32732d95841f78bd01872bea0640531260bb4c285207e0dd85bdaff922406b/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f7461672f666c7973797374656d2f6d696d652d747970652d646574656374696f6e2e737667)](https://github.com/flysystem/mime-type-detection/releases)[![Software License]()](https://github.com/flysystem/mime-type-detection/blob/master/LICENSE)[![Build Status](https://camo.githubusercontent.com/3305621e759e1959f092ab03552b1c373bb6799a42c8effa6a723dd9f710a4bc/68747470733a2f2f7472617669732d63692e6f72672f666c7973797374656d2f6d696d652d747970652d646574656374696f6e2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/flysystem/mime-type-detection)[![Coverage Status](https://camo.githubusercontent.com/3d83bba6b2496b27b27cc224389b956f30c6d4dfccc61d73f7e3ea8e5a96a79a/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f666c7973797374656d2f6d696d652d747970652d646574656374696f6e2e737667)](https://scrutinizer-ci.com/g/flysystem/mime-type-detection/code-structure)[![Quality Score](https://camo.githubusercontent.com/5902f69e9e89a360c09f0bf548fdd297f939142e0ebc43627dcea08c6982e3d5/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f666c7973797374656d2f6d696d652d747970652d646574656374696f6e2e737667)](https://scrutinizer-ci.com/g/flysystem/mime-type-detection)[![Total Downloads](https://camo.githubusercontent.com/f8b5555a25b170084ba0a32778880c787c2ba9eeef4959e7c7e3e62f10786b0e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f666c7973797374656d2f6d696d652d747970652d646574656374696f6e2e737667)](https://packagist.org/packages/flysystem/mime-type-detection)[![php 7.2+](https://camo.githubusercontent.com/2376755214318dbed6b54c54d063cd49a92f9116f93a173fca1952d529376fd6/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d6d696e253230372e322d7265642e737667)](https://camo.githubusercontent.com/2376755214318dbed6b54c54d063cd49a92f9116f93a173fca1952d529376fd6/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d6d696e253230372e322d7265642e737667)

This package supplies a generic mime-type detection interface with a `finfo` based implementation.

Usage
-----

[](#usage)

```
composer require flysystem/mime-type-detection
```

### Detectors

[](#detectors)

Finfo with extension fallback:

```
$detector = new Flysystem\MimeTypeDetection\FinfoMimeTypeDetector();

// Detect by contents, fall back to detection by extension.
$mimeType = $detector->detectMimeType('some/path.php', 'string contents');

// Detect by contents only, no extension fallback.
$mimeType = $detector->detectMimeTypeFromBuffer('string contents');

// Detect by actual file, no extension fallback.
$mimeType = $detector->detectMimeTypeFromFile('existing/path.php');

// Only detect by extension
$mimeType = $detector->detectMimeTypeFromPath('any/path.php');
```

Extension only:

```
$detector = new Flysystem\MimeTypeDetection\ExtensionMimeTypeDetector();

// Only detect by extension
$mimeType = $detector->detectMimeType('some/path.php', 'string contents');

// Always returns null
$mimeType = $detector->detectMimeTypeFromBuffer('string contents');

// Only detect by extension
$mimeType = $detector->detectMimeTypeFromFile('existing/path.php');

// Only detect by extension
$mimeType = $detector->detectMimeTypeFromPath('any/path.php');
```

Extension mime-type lookup
--------------------------

[](#extension-mime-type-lookup)

As a fallback for `finfo` based lookup, an extension map is used to determine the mime-type. There is an advised implementation shipped, which is generated from information collected by the npm package [mime-db](https://www.npmjs.com/package/mime-db).

### Provided extension maps

[](#provided-extension-maps)

Generated:

```
$map = new Flysystem\MimeTypeDetection\GeneratedExtensionToMimeTypeMap();

// string mime-type or NULL
$mimeType = $map->lookupMimeType('png');
```

Empty:

```
$map = new Flysystem\MimeTypeDetection\EmptyExtensionToMimeTypeMap();

// Always returns NULL
$mimeType = $map->lookupMimeType('png');
```

###  Health Score

17

—

LowBetter than 6% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity3

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity34

Early-stage or recently created project

 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.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/534693?v=4)[Frank de Jonge](/maintainers/frankdejonge)[@frankdejonge](https://github.com/frankdejonge)

---

Top Contributors

[![frankdejonge](https://avatars.githubusercontent.com/u/534693?v=4)](https://github.com/frankdejonge "frankdejonge (11 commits)")

### Embed Badge

![Health badge](/badges/flysystem-mime-type-detection/health.svg)

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

###  Alternatives

[delight-im/base64

Simple and convenient Base64 encoding and decoding for PHP

15158.1k6](/packages/delight-im-base64)

PHPackages © 2026

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