Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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: about 1 month 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 4 years ago)
- Default Branch: master
- Last Pushed: 2023-04-28T02:59:49.000Z (over 1 year ago)
- Last Synced: 2024-03-15T11:51:40.998Z (9 months 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
[![Build](https://github.com/asispts/http-accept/actions/workflows/ci.yml/badge.svg)](https://github.com/asispts/http-accept/actions/workflows/ci.yml)
[![Packagist PHP Version](https://img.shields.io/packagist/dependency-v/asispts/http-accept/php)](https://packagist.org/packages/asispts/http-accept)
[![Packagist Version](https://img.shields.io/packagist/v/asispts/http-accept?label=stable)](https://packagist.org/packages/asispts/http-accept)
[![License](https://img.shields.io/github/license/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.