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

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

brandembassy/file-type-detector
===============================

Detects file type by filename or content and generates correct mimetype. Forked from https://github.com/wapmorgan/FileTypeDetector

2.4.0(1mo ago)2217.6k—4.3%3MITPHPPHP ^8.2CI passing

Since Jan 9Pushed 2mo agoCompare

[ Source](https://github.com/BrandEmbassy/php-file-type-detector)[ Packagist](https://packagist.org/packages/brandembassy/file-type-detector)[ RSS](/packages/brandembassy-file-type-detector/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (6)Versions (36)Used By (3)

Project forked from

File Type Detector
==================

[](#file-type-detector)

Files type detector based on file name extension or file content (binary content).

File Type detection
-------------------

[](#file-type-detection)

- Detection by file name: `Detector::detectByFilename(...filename...): array|boolean`
- Detection by file content or stream content: `Detector::detectByContent(...filename/resource...): array|boolean`

Both functions will return an `array` with following elements in case of success:

- `[0]` - Type of file (`Detector::AUDIO` and so on)
- `[1]` - Format of file (`Detector::MP3` and so on)
- `[2]` - Mime type of file (`'audio/mpeg'` for example)

In case of failure it will return `false`.

Example:

```
$type = wapmorgan\FileTypeDetector\Detector::detectByFilename($filename);
// or
$type = wapmorgan\FileTypeDetector\Detector::detectByContent('file-without-extension');
// or
$type = wapmorgan\FileTypeDetector\Detector::detectByContent(fopen('http://somedomain/somepath', 'r'));
```

Mimetype resolving
------------------

[](#mimetype-resolving)

To get correct mimetype for file only there is `getMimeType($file)` function.

```
$mime = wapmorgan\FileTypeDetector\Detector::getMimeType($file);
// or
$mime = wapmorgan\FileTypeDetector\Detector::getMimeType(fopen('somefile', 'r'));
```

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

[](#installation)

```
composer require brandembassy/file-type-detector

```

###  Health Score

62

—

FairBetter than 99% of packages

Maintenance87

Actively maintained with recent releases

Popularity36

Limited adoption so far

Community20

Small or concentrated contributor base

Maturity87

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 66.7% 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 ~112 days

Recently: every ~257 days

Total

31

Last Release

59d ago

Major Versions

1.2 → 2.02021-01-19

1.2.1 → 2.0.32021-07-14

1.x-dev → 2.0.42022-08-08

PHP version history (2 changes)2.0.4PHP ^7.2 || ^8.0

2.4.0PHP ^8.2

### Community

Maintainers

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

---

Top Contributors

[![wapmorgan](https://avatars.githubusercontent.com/u/6000618?v=4)](https://github.com/wapmorgan "wapmorgan (52 commits)")[![jakubkulhanek](https://avatars.githubusercontent.com/u/6791232?v=4)](https://github.com/jakubkulhanek "jakubkulhanek (5 commits)")[![PetrHeinz](https://avatars.githubusercontent.com/u/10008612?v=4)](https://github.com/PetrHeinz "PetrHeinz (4 commits)")[![tomasJancar](https://avatars.githubusercontent.com/u/33625465?v=4)](https://github.com/tomasJancar "tomasJancar (4 commits)")[![dominikkaluza](https://avatars.githubusercontent.com/u/38032505?v=4)](https://github.com/dominikkaluza "dominikkaluza (3 commits)")[![signor-pedro](https://avatars.githubusercontent.com/u/53906348?v=4)](https://github.com/signor-pedro "signor-pedro (3 commits)")[![dominikvoda](https://avatars.githubusercontent.com/u/6583541?v=4)](https://github.com/dominikvoda "dominikvoda (3 commits)")[![rahuljain-nice](https://avatars.githubusercontent.com/u/208470271?v=4)](https://github.com/rahuljain-nice "rahuljain-nice (2 commits)")[![peter279k](https://avatars.githubusercontent.com/u/9021747?v=4)](https://github.com/peter279k "peter279k (1 commits)")[![dominik-vasicek](https://avatars.githubusercontent.com/u/57711297?v=4)](https://github.com/dominik-vasicek "dominik-vasicek (1 commits)")

---

Tags

filesmimetypeformatsfiletype

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/brandembassy-file-type-detector/health.svg)

```
[![Health](https://phpackages.com/badges/brandembassy-file-type-detector/health.svg)](https://phpackages.com/packages/brandembassy-file-type-detector)
```

###  Alternatives

[wapmorgan/file-type-detector

Detects file type by filename or content and generates correct mimetype.

35367.8k2](/packages/wapmorgan-file-type-detector)[lorisleiva/lody

Load files and classes as lazy collections in Laravel.

956.6M9](/packages/lorisleiva-lody)[dfridrich/php-mime-type

Simple PHP class for guessing file mime type based on file extension with ability to use in Symfony project.

17274.8k3](/packages/dfridrich-php-mime-type)[colinodell/indentation

Library to detect and manipulate indentation in strings and files

3911.5k5](/packages/colinodell-indentation)

PHPackages © 2026

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