PHPackages                             noresources/mediatype - 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. noresources/mediatype

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

noresources/mediatype
=====================

Media Type parsing and manipulation library

v2.0.1(1y ago)01432MITPHPPHP &gt;= 7.1CI passing

Since Jun 27Pushed 1y ago1 watchersCompare

[ Source](https://github.com/noresources/php-mediatype)[ Packagist](https://packagist.org/packages/noresources/mediatype)[ RSS](/packages/noresources-mediatype/feed)WikiDiscussions main Synced 3w ago

READMEChangelogDependencies (2)Versions (35)Used By (2)

noresources/mediatype
=====================

[](#noresourcesmediatype)

RFC 6838 Media Type (MIME type) parsing and comparison.

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

[](#installation)

```
composer require noresources/mediatype
```

Usage
-----

[](#usage)

```
use NoreSources\MediaType\MediaType;
use NoreSources\MediaType\MediaTypeFactory;
use NoreSources\MediaType\MediaRange;

$factory = MediaTypeFactory::getInstance();
$mediaType = $factory->createFromString('text/vnd.noresources.incredibly.flexible+xml');

var_dump($mediaType->getMainType());         // "text"
var_dump($mediaType->getStructuredSyntax()); // "xml"

$subType = $mediaType->getSubType();
var_dump(\strval($subType));                 // "vnd.noresources.incredibly.flexible+xml"
var_dump($subType->getFacets());             // [ "vnd", "noresources", "incredibly", "flexible" ]

// From a file or a stream
$mediaType = $factory->createFromMedia('path/to/filename.html');
var_dump(\strval($mediaType)); // "text/html"

// Media range is also recognized
$range = $factory->createFromString('image/*');

// Comparing
$html = $factory->createFromString('text/html');
$anyText = $factory->createFromString('text/*');
$any = $factory->createFromString('*/*');

var_dump([
	'text/html vs text/*' => MediaRange::compare($html, $anyText),
	'text/* vs */*' => MediaRange::compare($anyText, $any),
	'*/* vs text/html' => MediaRange::compare($any, $html)
]);

/*
array(3) {
  ["text/html vs text/*"]=> int(1)
  ["text/* vs */*"]=> int(1)
  ["*/* vs text/html"]=> int(-1)
}
*/
```

References
----------

[](#references)

- [RFC 6838 Media Type Specifications and Registration Procedures](https://tools.ietf.org/html/rfc6838)
- [RFC 4288](https://tools.ietf.org/html/rfc4288#section-4.3)
- [RFC 7231 Hypertext Transfer Protocol (HTTP/1.1): Semantics and Content](https://tools.ietf.org/html/rfc7231#section-3.1.1.1)
- [IANA Media Type registration list](https://www.iana.org/assignments/media-types/media-types.xhtml)
- [Apache Media Type file extensions associations](https://svn.apache.org/repos/asf/httpd/httpd/trunk/docs/conf/mime.types)

###  Health Score

36

—

LowBetter than 79% of packages

Maintenance47

Moderate activity, may be stable

Popularity12

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 98.2% 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 ~56 days

Recently: every ~100 days

Total

33

Last Release

390d ago

Major Versions

1.7.x-dev → v2.0.02024-11-06

PHP version history (3 changes)1.0.x-devPHP &gt;= 5.5

v1.2.0PHP &gt;= 5.6

v2.0.0PHP &gt;= 7.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/74b6302d665dc6bee0c92caf49bb2d6a9c9d068203e7e7b034f3bca90bda6636?d=identicon)[noresources](/maintainers/noresources)

---

Top Contributors

[![noresources](https://avatars.githubusercontent.com/u/4061622?v=4)](https://github.com/noresources "noresources (54 commits)")[![Kiina](https://avatars.githubusercontent.com/u/2419591?v=4)](https://github.com/Kiina "Kiina (1 commits)")

---

Tags

mimemedia typeRFC 6838

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/noresources-mediatype/health.svg)

```
[![Health](https://phpackages.com/badges/noresources-mediatype/health.svg)](https://phpackages.com/packages/noresources-mediatype)
```

###  Alternatives

[symfony/mime

Allows manipulating MIME messages

2.8k700.2M1.2k](/packages/symfony-mime)[zbateson/mail-mime-parser

MIME email message parser

54551.9M86](/packages/zbateson-mail-mime-parser)[php-mime-mail-parser/php-mime-mail-parser

A fully tested email parser for PHP 8.2+ (mailparse extension wrapper).

99310.1M35](/packages/php-mime-mail-parser-php-mime-mail-parser)[nette/mail

📧 Nette Mail: A handy library for creating and sending emails in PHP.

49210.1M268](/packages/nette-mail)[zbateson/stream-decorators

PHP psr7 stream decorators for mime message part streams

4751.2M7](/packages/zbateson-stream-decorators)[dflydev/apache-mime-types

Apache MIME Types

702.0M37](/packages/dflydev-apache-mime-types)

PHPackages © 2026

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