Skip to content

PHP Parser to deal with HTTP Accept, Accept-Language, Accept-Encoding, and Content-Type headers

License

Notifications You must be signed in to change notification settings

asispts/http-accept

Repository files navigation

Build Packagist PHP Version Packagist Version License

http-accept parser

http-accept is a PHP parser designed to handle HTTP headers related to content negotiation. These headers include Accept, Accept-Language, Accept-Encoding, and Content-Type. The library provides parser classes for each of these headers, making it easy to extract the relevant information from incoming HTTP requests.

Installation

You can install this library using composer.

composer require asispts/http-accept

Usage

To parse the different headers, use the corresponding parser class.

Parse Content-Type

$contentType = (new ContentTypeParser())->parse($source);

Parse HTTP Accept

$types = (new AcceptParser())->parse($source);

Parse Accept-Language

$languages = (new AcceptLanguageParser())->parse($source);

Parse Accept-Encoding

$encodings = (new AcceptEncodingParser())->parse($source);

Contributing

All forms of contributions are welcome, including bug reports, feature requests, and pull requests. If you plan to make major changes, please open an issue first to discuss what you would like to change.

License

Released under Apache-2.0 License. See LICENSE file for more details.