PHPackages                             cosmicvelocity/media-types - 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. cosmicvelocity/media-types

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

cosmicvelocity/media-types
==========================

Detect the Media Type (MIME Type) of a file or extentions.

1.2(8y ago)239[1 issues](https://github.com/cosmicvelocity/media-types/issues)1Apache-2.0PHPPHP ^5.4|^7.0

Since Jul 23Pushed 8y ago1 watchersCompare

[ Source](https://github.com/cosmicvelocity/media-types)[ Packagist](https://packagist.org/packages/cosmicvelocity/media-types)[ RSS](/packages/cosmicvelocity-media-types/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (3)Dependencies (1)Versions (4)Used By (1)

cosmicvelocity/media-types
==========================

[](#cosmicvelocitymedia-types)

A PHP library for handling media types.

- Supports the RFC 6838 specification.
- MIME type character string analysis can be performed.
- Supports automatic detection from filename with built-in mapping list.
- Supports automatic detection by Fileinfo extension.

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

[](#installation)

If composer is used, it can be introduced by adding the following description.

```
  "require": {
    "cosmicvelocity/media-types": ">=1.0"
  }

```

How to use
----------

[](#how-to-use)

- When detecting from file name.

    ```
    $mediaTypes = new PhpArrayMediaTypes();
    $mediaType = $mediaTypes->getMediaType('sample.txt');

    $mediaType->getType(); // text

    ```
- To detect from your own mapping.

    ```
    $mediaTypes = new PhpArrayMediaTypes([
       'hoge' => 'application/prs.hoge+xml'
    ]);
    $mediaType = $mediaTypes->getMediaType('sample.hoge');

    $mediaType->getType();    // application
    $mediaType->getSubType(); // prs.hoge+xml
    $mediaType->getTree();  // prs
    $mediaType->getSuffix();  // xml

    ```
- When analyzing MIME type.

    ```
    $mediaType = MediaType::fromMime('application/calendar+json; charset=utf-8');

    $mediaType->getType();    // application
    $mediaType->getSubType(); // calendar+json
    $mediaType->getSuffix();  // json
    $mediaType->getParameter('charset')->getValue(); // utf-8

    ```
- When detecting from a file.

    ```
    $mediaType = MediaType::fromFile('sample.json');

    $mediaType->getType();    // text
    $mediaType->getSubType(); // plain

    ```

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance10

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity60

Established project with proven stability

 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

Every ~131 days

Total

3

Last Release

2950d ago

PHP version history (2 changes)1.0PHP ^5.6|^7.0

1.2PHP ^5.4|^7.0

### Community

Maintainers

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

---

Top Contributors

[![cosmicvelocity](https://avatars.githubusercontent.com/u/1166307?v=4)](https://github.com/cosmicvelocity "cosmicvelocity (20 commits)")

---

Tags

phpmimemimetypesmediatypecontenttype

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/cosmicvelocity-media-types/health.svg)

```
[![Health](https://phpackages.com/badges/cosmicvelocity-media-types/health.svg)](https://phpackages.com/packages/cosmicvelocity-media-types)
```

###  Alternatives

[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)[dflydev/apache-mime-types

Apache MIME Types

701.9M35](/packages/dflydev-apache-mime-types)[silverstripe/mimevalidator

Checks uploaded file content roughly matches a known MIME type for the file extension.

102.0M9](/packages/silverstripe-mimevalidator)[tomatophp/filament-accounts

Manage your multi accounts inside your app using 1 table with multi auth and a lot of integrations

748.3k7](/packages/tomatophp-filament-accounts)[djunehor/laravel-sms

Send SMS from your laravel application

385.3k1](/packages/djunehor-laravel-sms)

PHPackages © 2026

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