https://github.com/asispts/http-accept
PHP Parser to deal with HTTP Accept, Accept-Language, Accept-Encoding, and Content-Type headers
https://github.com/asispts/http-accept
accept accept-encoding accept-language content-type http-header-parser http-headers
Last synced: 9 months ago
JSON representation
PHP Parser to deal with HTTP Accept, Accept-Language, Accept-Encoding, and Content-Type headers
- Host: GitHub
- URL: https://github.com/asispts/http-accept
- Owner: asispts
- License: apache-2.0
- Created: 2020-08-26T06:53:13.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-04-28T02:59:49.000Z (over 2 years ago)
- Last Synced: 2024-03-15T11:51:40.998Z (almost 2 years ago)
- Topics: accept, accept-encoding, accept-language, content-type, http-header-parser, http-headers
- Language: PHP
- Homepage:
- Size: 93.8 KB
- Stars: 5
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://github.com/asispts/http-accept/actions/workflows/ci.yml)
[](https://packagist.org/packages/asispts/http-accept)
[](https://packagist.org/packages/asispts/http-accept)
[](./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](https://getcomposer.org/).
```bash
composer require asispts/http-accept
```
## Usage
To parse the different headers, use the corresponding parser class.
### Parse `Content-Type`
```php
$contentType = (new ContentTypeParser())->parse($source);
```
### Parse HTTP `Accept`
```php
$types = (new AcceptParser())->parse($source);
```
### Parse `Accept-Language`
```php
$languages = (new AcceptLanguageParser())->parse($source);
```
### Parse `Accept-Encoding`
```php
$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](https://opensource.org/licenses/Apache-2.0). See [LICENSE](./LICENSE) file for more details.