PHPackages                             softcreatr/php-mime-detector - 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. [Testing &amp; Quality](/categories/testing)
4. /
5. softcreatr/php-mime-detector

ActiveLibrary[Testing &amp; Quality](/categories/testing)

softcreatr/php-mime-detector
============================

Modern, extensible MIME type detector for PHP

5.1.1(3mo ago)26344.8k↓22.2%43ISCPHPPHP &gt;=8.1.0CI passing

Since Oct 15Pushed 3mo ago3 watchersCompare

[ Source](https://github.com/SoftCreatR/php-mime-detector)[ Packagist](https://packagist.org/packages/softcreatr/php-mime-detector)[ Docs](https://1-2.dev)[ GitHub Sponsors](https://github.com/softcreatr)[ RSS](/packages/softcreatr-php-mime-detector/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (3)Versions (12)Used By (3)

PHP Mime Detector
=================

[](#php-mime-detector)

A modern, extensible MIME type detector for PHP that analyses the actual bytes of a file instead of trusting its extension. The detector ships with a modular pipeline of signature matchers and a bidirectional repository of MIME type ↔ extension mappings so you can integrate it into security-sensitive workflows.

Features
--------

[](#features)

- **Real file inspection** – identifies file formats by signature instead of relying on filenames. You can find a list of supported file formats in the [Wiki](https://github.com/SoftCreatR/php-mime-detector/wiki/Supported-file-types).
- **Composable architecture** – category-specific detectors can be swapped in or extended without touching the core.
- **Rich lookup helpers** – translate between MIME types and extensions in both directions and enumerate the supported catalogue.
- **No external dependencies** – runs on any PHP 8.1+ installation without and can take requiring additional, external extensions, or packages, but takes advantage of `ZipArchive` when it is available.

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

[](#installation)

Install the package via Composer:

```
composer require softcreatr/php-mime-detector
```

Quick start
-----------

[](#quick-start)

Detecting the MIME type and the preferred extension for a file is as simple as instantiating the façade and calling its helpers:

```
