PHPackages                             innmind/media-type - 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. innmind/media-type

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

innmind/media-type
==================

Model of media types

3.0.0(3mo ago)088.6k↓17.2%4MITPHPPHP ~8.4CI passing

Since Dec 14Pushed 3mo ago1 watchersCompare

[ Source](https://github.com/Innmind/MediaType)[ Packagist](https://packagist.org/packages/innmind/media-type)[ Docs](http://github.com/Innmind/MediaType)[ RSS](/packages/innmind-media-type/feed)WikiDiscussions develop Synced 1mo ago

READMEChangelog (5)Dependencies (4)Versions (19)Used By (4)

MediaType
=========

[](#mediatype)

[![Build Status](https://github.com/innmind/mediatype/workflows/CI/badge.svg?branch=master)](https://github.com/innmind/mediatype/actions?query=workflow%3ACI)[![codecov](https://camo.githubusercontent.com/d636032f77a038c8cb746817061412bd7ee6b3543942607e6cc55c9ac3d91eba/68747470733a2f2f636f6465636f762e696f2f67682f696e6e6d696e642f6d65646961747970652f6272616e63682f646576656c6f702f67726170682f62616467652e737667)](https://codecov.io/gh/innmind/mediatype)[![Type Coverage](https://camo.githubusercontent.com/91fe0dcc88c7ff19dc272e29bf9c1ffaf644b119e0312f69e2371829eea7fcc2/68747470733a2f2f73686570686572642e6465762f6769746875622f696e6e6d696e642f6d65646961747970652f636f7665726167652e737667)](https://shepherd.dev/github/innmind/mediatype)

Model to validate media types (follows [RFC6838](https://tools.ietf.org/html/rfc6838)).

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

[](#installation)

```
composer install innmind/media-type
```

Usage
-----

[](#usage)

```
use Innmind\MediaType\MediaType;

$type = MediaType::of('application/json+some-extension; charset=utf-8');
$type->topLevel(); // application
$type->subType(); // json
$type->suffix(); // some-extension
$type->parameters()->first()->name(); // charset
$type->parameters()->first()->value(); // utf-8
$type->toString(); // application/json+some-extension; charset=utf-8
```

If the values are incorrect it will throw an exception. Or you can use `MediaType::maybe()` that will return an instance of `Innmind\Immutable\Maybe`.

###  Health Score

56

—

FairBetter than 98% of packages

Maintenance78

Regular maintenance activity

Popularity31

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity83

Battle-tested with a long release history

 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 ~139 days

Recently: every ~269 days

Total

17

Last Release

113d ago

Major Versions

1.3.2 → 2.0.02022-01-15

1.x-dev → 2.0.12023-02-12

2.3.0 → 3.0.02026-01-25

PHP version history (5 changes)1.0.0PHP ~7.4

1.3.0PHP ~7.4|~8.0

2.0.0PHP ~8.0

2.1.0PHP ~8.2

3.0.0PHP ~8.4

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/851425?v=4)[Baptiste Langlade](/maintainers/Baptouuuu)[@Baptouuuu](https://github.com/Baptouuuu)

---

Top Contributors

[![Baptouuuu](https://avatars.githubusercontent.com/u/851425?v=4)](https://github.com/Baptouuuu "Baptouuuu (94 commits)")

---

Tags

media type

### Embed Badge

![Health badge](/badges/innmind-media-type/health.svg)

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

###  Alternatives

[webignition/internet-media-type

PHP model of an http://en.wikipedia.org/wiki/Internet\_media\_type

10146.2k13](/packages/webignition-internet-media-type)

PHPackages © 2026

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