http-accept
is a PHP library for parsing HTTP headers used in content negotiation. It supports the following headers:
Accept
Accept-Language
Accept-Encoding
Content-Type
Parser classes are provided for each header, making it straightforward to extract information from incoming requests.
Install via Composer:
composer require asispts/http-accept
Use the corresponding parser class for each header.
$contentType = (new ContentTypeParser())->parse($source);
$types = (new AcceptParser())->parse($source);
$languages = (new AcceptLanguageParser())->parse($source);
$encodings = (new AcceptEncodingParser())->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.