hnet/http-accept

This package is abandoned and no longer maintained. The author suggests using the asispts/http-accept package instead.

PHP parser for HTTP Accept, Accept-Language, Accept-Encoding, and Content-Type headers.

Installs: 7 310

Dependents: 0

Suggesters: 0

Security: 0

Stars: 5

Watchers: 2

Forks: 1

Open Issues: 0

pkg:composer/hnet/http-accept

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

README

http-accept

» PHP parser for HTTP content negotiation headers «

 

Build License PHP Version Stable Version Downloads

 

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.

 

Installation

Install via Composer:

composer require asispts/http-accept

 

Usage

Use the corresponding parser class for each header.

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

Contributions are welcome—whether bug reports, feature requests, or pull requests. For major changes, please open an issue first to discuss your ideas.

 

License

Licensed under the Apache-2.0 License. See the LICENSE file for details.