asispts / http-accept
PHP Parser to deal with HTTP Accept, Accept-Language, Accept-Encoding, and Content-Type headers
Installs: 10 856
Dependents: 4
Suggesters: 0
Security: 0
Stars: 5
Watchers: 2
Forks: 1
Open Issues: 0
Requires
- php: ^7.2|^8.0
Requires (Dev)
- asispts/ptscs: ^1.0
- phpstan/phpstan: ^1.4
- phpstan/phpstan-phpunit: ^1.0
- phpunit/phpunit: ^8.5|^9.5|^10.0
This package is auto-updated.
Last update: 2024-10-28 10:42:40 UTC
README
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.