http-accept is a PHP library for parsing HTTP headers used in content negotiation. It supports the following headers:
AcceptAccept-LanguageAccept-EncodingContent-Type
Parser classes are provided for each header, making it straightforward to extract information from incoming requests.
Install via Composer:
composer require asispts/http-acceptUse the corresponding parser class for each header.
$contentType = (newContentTypeParser())->parse($source);$types = (newAcceptParser())->parse($source);$languages = (newAcceptLanguageParser())->parse($source);$encodings = (newAcceptEncodingParser())->parse($source);Contributions are welcome—whether bug reports, feature requests, or pull requests. For major changes, please open an issue first to discuss your ideas.
Licensed under the Apache-2.0 License. See the LICENSE file for details.