{"id":15578321,"url":"https://github.com/conneg/mimeparse-php","last_synced_at":"2025-04-14T22:45:21.766Z","repository":{"id":3979260,"uuid":"5074782","full_name":"conneg/mimeparse-php","owner":"conneg","description":"Basic functions for handling mime-types, forked from Joe Gregorio's mimeparse library","archived":false,"fork":false,"pushed_at":"2019-06-03T00:53:53.000Z","size":75,"stargazers_count":36,"open_issues_count":0,"forks_count":8,"subscribers_count":6,"default_branch":"master","last_synced_at":"2024-04-26T20:47:37.025Z","etag":null,"topics":["conneg","content-negotiation","mime","mime-parser","php"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/conneg.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-07-16T23:05:59.000Z","updated_at":"2024-03-26T12:14:54.000Z","dependencies_parsed_at":"2022-08-30T06:01:07.719Z","dependency_job_id":null,"html_url":"https://github.com/conneg/mimeparse-php","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/conneg%2Fmimeparse-php","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/conneg%2Fmimeparse-php/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/conneg%2Fmimeparse-php/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/conneg%2Fmimeparse-php/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/conneg","download_url":"https://codeload.github.com/conneg/mimeparse-php/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248975293,"owners_count":21192199,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["conneg","content-negotiation","mime","mime-parser","php"],"created_at":"2024-10-02T19:08:44.159Z","updated_at":"2025-04-14T22:45:21.515Z","avatar_url":"https://github.com/conneg.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# bitworking/mimeparse\n\n[![Source Code][badge-source]][source]\n[![Latest Version][badge-release]][release]\n[![Software License][badge-license]][license]\n[![Build Status][badge-build]][build]\n[![Scrutinizer][badge-quality]][quality]\n[![Coverage Status][badge-coverage]][coverage]\n[![Total Downloads][badge-downloads]][downloads]\n\nThis library provides basic functionality for parsing mime-types names and matching them against a list of media-ranges. See [section 5.3.2][http-accept] of [RFC 7231 (HTTP semantics and content specification)][http] for a complete explanation. More information on the library can be found in the XML.com article \"[Just use Media Types?][jgregorio-restful]\"\n\nThis library was taken from the [original mimeparse library][mimeparse] on Google Project Hosting and has been cleaned up to conform to [PSR-1][], [PSR-2][], and [PSR-4][] standards. It also now has support for [Composer][]. The Bitworking namespace is a nod to [Joe Gregorio][jgregorio], the original author of this library.\n\n## Installation\n\nThe preferred method of installation is via [Packagist][] and [Composer][]. Run the following command to install the package and add it as a requirement to your project's `composer.json`:\n\n```bash\ncomposer require bitworking/mimeparse\n```\n\n## Examples\n\nUse 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][http-accept] 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.\n\n```php\n\u003c?php\n$supportedTypes = array('application/xbel+xml', 'text/xml');\n$httpAcceptHeader = 'text/*;q=0.5,*/*; q=0.1';\n\n$mimeType = \\Bitworking\\Mimeparse::bestMatch($supportedTypes, $httpAcceptHeader);\n\necho $mimeType; // Should echo \"text/xml\"\n```\n\nYou 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).\n\n```php\n\u003c?php\n$httpAcceptHeader = 'text/*;q=0.3, text/html;q=0.7, text/html;level=1, text/html;level=2;q=0.4, *\\/*;q=0.5';\n\n$quality = \\Bitworking\\Mimeparse::quality('text/html', $httpAcceptHeader);\n\necho $quality; // Should echo 0.7\n```\n\n## Contributing\n\nContributions are welcome! Please read [CONTRIBUTING][] for details.\n\n## Copyright and license\n\nThe original mimeparse library is copyright © [Joe Gregorio][jgregorio]. The bitworking/mimeparse library for PHP is copyright © [Ben Ramsey][]. Both authors have licensed the source for use under the MIT License (MIT). Please see [LICENSE][] for more information.\n\n\n[http-accept]: http://tools.ietf.org/html/rfc7231#section-5.3.2\n[http]: http://tools.ietf.org/html/rfc7231\n[jgregorio-restful]: http://www.xml.com/pub/a/2005/06/08/restful.html\n[mimeparse]: https://github.com/conneg/mimeparse\n[PSR-1]: http://www.php-fig.org/psr/psr-1/\n[PSR-2]: http://www.php-fig.org/psr/psr-2/\n[PSR-4]: http://www.php-fig.org/psr/psr-4/\n[composer]: http://getcomposer.org/\n[jgregorio]: http://bitworking.org/\n[ben ramsey]: https://benramsey.com/\n[packagist]: https://packagist.org/packages/bitworking/mimeparse\n[contributing]: https://github.com/conneg/mimeparse-php/blob/master/CONTRIBUTING.md\n\n[badge-source]: https://img.shields.io/badge/source-conneg/mimeparse--php-blue.svg?style=flat-square\n[badge-release]: https://img.shields.io/packagist/v/bitworking/mimeparse.svg?style=flat-square\n[badge-license]: https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square\n[badge-build]: https://img.shields.io/travis/conneg/mimeparse-php/master.svg?style=flat-square\n[badge-quality]: https://img.shields.io/scrutinizer/g/conneg/mimeparse-php/master.svg?style=flat-square\n[badge-coverage]: https://img.shields.io/coveralls/conneg/mimeparse-php/master.svg?style=flat-square\n[badge-downloads]: https://img.shields.io/packagist/dt/bitworking/mimeparse.svg?style=flat-square\n\n[source]: https://github.com/conneg/mimeparse-php\n[release]: https://packagist.org/packages/bitworking/mimeparse\n[license]: https://github.com/conneg/mimeparse-php/blob/master/LICENSE\n[build]: https://travis-ci.org/conneg/mimeparse-php\n[quality]: https://scrutinizer-ci.com/g/conneg/mimeparse-php/\n[coverage]: https://coveralls.io/r/conneg/mimeparse-php?branch=master\n[downloads]: https://packagist.org/packages/bitworking/mimeparse\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fconneg%2Fmimeparse-php","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fconneg%2Fmimeparse-php","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fconneg%2Fmimeparse-php/lists"}