asispts/http-accept

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

v1.0.0 2023-04-28 02:59 UTC

This package is auto-updated.

Last update: 2024-11-28 10:46:09 UTC


README

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.