PHPackages                             bitworking/mimeparse - 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. [HTTP &amp; Networking](/categories/http)
4. /
5. bitworking/mimeparse

ActiveLibrary[HTTP &amp; Networking](/categories/http)

bitworking/mimeparse
====================

Basic functions for handling mime-types.

2.3.0(1y ago)41213.9k—4.1%11[2 PRs](https://github.com/conneg/mimeparse-php/pulls)1MITPHPPHP ^7.4 || ^8.0CI passing

Since Jul 17Pushed 3mo ago5 watchersCompare

[ Source](https://github.com/conneg/mimeparse-php)[ Packagist](https://packagist.org/packages/bitworking/mimeparse)[ RSS](/packages/bitworking-mimeparse/feed)WikiDiscussions main Synced 2d ago

READMEChangelog (8)Dependencies (12)Versions (10)Used By (1)

bitworking/mimeparse
====================

[](#bitworkingmimeparse)

 **Basic functions for handling mime-types**

 [![Source Code](https://camo.githubusercontent.com/7059366dc3f6544683e3981464b1765ea8e40c35d4de946022170cc24fbd59a6/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f736f757263652d626974776f726b696e672f6d696d6570617273652d626c75652e7376673f7374796c653d666c61742d737175617265)](https://github.com/conneg/mimeparse-php) [![Download Package](https://camo.githubusercontent.com/21aeaa1326605520a53513278a7915f57fe7a781bc690c8a5d3bf28de362f93f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f626974776f726b696e672f6d696d6570617273652e7376673f7374796c653d666c61742d737175617265266c6162656c3d72656c65617365)](https://packagist.org/packages/bitworking/mimeparse) [![PHP Programming Language](https://camo.githubusercontent.com/f212930b3faf63f27458a9c44004c176c3fbef53e65648a896f94fcc1cee0058/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f626974776f726b696e672f6d696d6570617273652e7376673f7374796c653d666c61742d73717561726526636f6c6f72423d253233383839324246)](https://php.net) [![Read License](https://camo.githubusercontent.com/4e614c2a51218c384e2a9d5bfc84f96049fa1f0c205b91ab6e23e95539b2e962/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f626974776f726b696e672f6d696d6570617273652e7376673f7374796c653d666c61742d73717561726526636f6c6f72423d6461726b6379616e)](https://github.com/conneg/mimeparse-php/blob/main/LICENSE) [![Build Status](https://camo.githubusercontent.com/ea937ffd6d667b7417b0d8302c094542386a017539ce91d4386157aa968372fb/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f636f6e6e65672f6d696d6570617273652d7068702f636f6e74696e756f75732d696e746567726174696f6e2e796d6c3f6272616e63683d6d61696e267374796c653d666c61742d737175617265266c6f676f3d676974687562)](https://github.com/conneg/mimeparse-php/actions/workflows/continuous-integration.yml) [![Codecov Code Coverage](https://camo.githubusercontent.com/08b96b205c657f6fb949da878e511877fac4effc0599cbdcd0bd10123fbe1afb/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636f762f632f67682f636f6e6e65672f6d696d6570617273652d7068703f6c6162656c3d636f6465636f76266c6f676f3d636f6465636f76267374796c653d666c61742d737175617265)](https://codecov.io/gh/conneg/mimeparse-php)

About
-----

[](#about)

This library provides basic functionality for parsing mime-types names and matching them against a list of media-ranges. See [RFC 9110, section 5.3.2](https://www.rfc-editor.org/rfc/rfc9110.html#section-12.5.1)for a complete explanation. More information on the library can be found in the XML.com article "[Just use Media Types?](http://www.xml.com/pub/a/2005/06/08/restful.html)"

This library was forked from the [original mimeparse library](https://github.com/conneg/mimeparse)on Google Project Hosting. The `Bitworking` namespace is a nod to original author [Joe Gregorio](https://bitworking.org/).

This project adheres to a [code of conduct](CODE_OF_CONDUCT.md). By participating in this project and its community, you are expected to uphold this code.

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

[](#installation)

Install this package as a dependency using [Composer](https://getcomposer.org).

```
composer require bitworking/mimeparse
```

Usage
-----

[](#usage)

Use Mimeparse to specify a list of media types your application supports and compare that to the list of media types the user agent accepts (via the [HTTP Accept](https://www.rfc-editor.org/rfc/rfc9110.html#section-12.5.1) header; `$_SERVER['HTTP_ACCEPT']`). Mimeparse will give you the best match to send back to the user agent for your list of supported types or `null` if there is no best match.

```
$supportedTypes = ['application/xbel+xml', 'text/xml'];
$httpAcceptHeader = 'text/*;q=0.5,*/*; q=0.1';

$mimeType = \Bitworking\Mimeparse::bestMatch($supportedTypes, $httpAcceptHeader);

echo $mimeType; // Should echo "text/xml"
```

You may also use Mimeparse to get the quality value of a specific media type when compared against a range of media types (from the `Accept` header, for example).

```
$httpAcceptHeader = 'text/*;q=0.3, text/html;q=0.7, text/html;level=1, text/html;level=2;q=0.4, *\/*;q=0.5';

$quality = \Bitworking\Mimeparse::quality('text/html', $httpAcceptHeader);

echo $quality; // Should echo 0.7
```

Contributing
------------

[](#contributing)

Contributions are welcome! To contribute, please familiarize yourself with [CONTRIBUTING.md](CONTRIBUTING.md).

Coordinated Disclosure
----------------------

[](#coordinated-disclosure)

Keeping user information safe and secure is a top priority, and we welcome the contribution of external security researchers. If you believe you've found a security issue in software that is maintained in this repository, please read [SECURITY.md](SECURITY.md) for instructions on submitting a vulnerability report.

Copyright and License
---------------------

[](#copyright-and-license)

bitworking/mimeparse is copyright © [Ben Ramsey](https://ben.ramsey.dev)and licensed for use under the terms of the MIT License (MIT).

The original mimeparse.php library is copyright © [Joe Gregorio](https://bitworking.org/)and licensed for use under the terms of the MIT License (MIT).

Please see [LICENSE](LICENSE) for more information.

###  Health Score

56

—

FairBetter than 97% of packages

Maintenance65

Regular maintenance activity

Popularity48

Moderate usage in the ecosystem

Community20

Small or concentrated contributor base

Maturity74

Established project with proven stability

 Bus Factor1

Top contributor holds 59.6% 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 ~663 days

Recently: every ~1012 days

Total

8

Last Release

459d ago

Major Versions

1.1.1 → 2.0.02012-09-18

PHP version history (3 changes)1.1.1PHP &gt;=5.3.3

2.1.0PHP &gt;=5.3.2

2.3.0PHP ^7.4 || ^8.0

### Community

Maintainers

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

---

Top Contributors

[![ramsey](https://avatars.githubusercontent.com/u/42941?v=4)](https://github.com/ramsey "ramsey (34 commits)")[![mkantor](https://avatars.githubusercontent.com/u/35091?v=4)](https://github.com/mkantor "mkantor (14 commits)")[![marijn](https://avatars.githubusercontent.com/u/65233?v=4)](https://github.com/marijn "marijn (6 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (3 commits)")

---

Tags

acceptconnegcontent-negotiationhttpmimemime-parserphphttpmimeacceptcontent negotiationconneg

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/bitworking-mimeparse/health.svg)

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

###  Alternatives

[guzzlehttp/psr7

PSR-7 message implementation that also provides common utility methods

8.0k1.1B4.0k](/packages/guzzlehttp-psr7)[psr/http-message

Common interface for HTTP messages

7.0k1.1B6.9k](/packages/psr-http-message)[psr/http-factory

PSR-17: Common interfaces for PSR-7 HTTP message factories

1.9k747.1M2.6k](/packages/psr-http-factory)[psr/http-client

Common interface for HTTP clients

1.7k731.6M2.9k](/packages/psr-http-client)[psr/link

Common interfaces for HTTP links

2.5k152.8M84](/packages/psr-link)[rmccue/requests

A HTTP library written in PHP, for human beings.

3.6k37.1M281](/packages/rmccue-requests)

PHPackages © 2026

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