PHPackages                             zozlak/http-accept - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. zozlak/http-accept

ActiveLibrary

zozlak/http-accept
==================

Set of methods to deal with the HTTP Accept header

1.0.0(2mo ago)17.9k↓11.8%4MITPHPPHP &gt;=8.1CI passing

Since Jul 30Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/zozlak/httpAccept)[ Packagist](https://packagist.org/packages/zozlak/http-accept)[ Docs](https://github.com/zozlak/httpAccept)[ RSS](/packages/zozlak-http-accept/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)Dependencies (2)Versions (3)Used By (4)

[![Latest Stable Version](https://camo.githubusercontent.com/42c74b8b6b5669bde1dbf45c4ecdde69922d69db86644e53e4bc2ceae69d1d2f/68747470733a2f2f706f7365722e707567782e6f72672f7a6f7a6c616b2f687474702d6163636570742f762f737461626c65)](https://packagist.org/packages/zozlak/http-accept)[![Build status](https://github.com/zozlak/httpAccept/workflows/phpunit/badge.svg?branch=master)](https://github.com/zozlak/httpAccept/workflows/phpunit/badge.svg?branch=master)[![Coverage Status](https://camo.githubusercontent.com/c6a6fee366c0a81f6c321d5cdb11b23da91a2373ff731586f997d321215e1793/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f7a6f7a6c616b2f687474704163636570742f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/zozlak/httpAccept?branch=master)[![License](https://camo.githubusercontent.com/695b84010e6ec825957b07cf70ba95661b47b10afee2436b54c1be75ff4997e3/68747470733a2f2f706f7365722e707567782e6f72672f7a6f7a6c616b2f687474702d6163636570742f6c6963656e7365)](https://packagist.org/packages/zozlak/http-accept)

HttpAccept
==========

[](#httpaccept)

A static class making it easier to deal with the HTTP Accept header.

Can be also used to deal with other HTTP headers which provide multiple options with weights, e.g. the Accept-Encoding one.

installation
------------

[](#installation)

`composer require zozlak/http-accept`

usage
-----

[](#usage)

```
// Simplest use - parse the HTTP Accept header
// e.g. for an Accept header of
//   text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
// the result is `application/xml;q=0.9`
$header = zozlak\httpAccept\Accept::fromHeader();
$bestMatch = $header->getBestMatch(['application/json', 'application/xml']);
echo (string) $bestMatch . "\n";

// Deal with Accept-Encoding
$header = zozlak\httpAccept\Accept::fromHeader('accept-encoding');
try {
    $bestMatch = $header->getBestMatch(['deflate']);
} catch (zozlak\httpAccept\NoMatchException) {
    $bestMatch = new zozlak\httpAccept\Format('identity');
}
echo $bestMatch->type . "\n";

// Check if two formats match
$format1 = zozlak\httpAccept\Format::fromString('application/xml');
$format2 = new zozlak\httpAccept\Format('application', '*');
var_dump($format1->matches($format2));
```

###  Health Score

51

—

FairBetter than 96% of packages

Maintenance84

Actively maintained with recent releases

Popularity26

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity68

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~2394 days

Total

2

Last Release

81d ago

Major Versions

0.1.0 → 1.0.02026-02-17

PHP version history (2 changes)0.1.0PHP &gt;=7.0

1.0.0PHP &gt;=8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/f1f662e3acb95efd9208cdcd2c97437db366044aea705985251760efcbd23070?d=identicon)[zozlak](/maintainers/zozlak)

---

Top Contributors

[![zozlak](https://avatars.githubusercontent.com/u/6503177?v=4)](https://github.com/zozlak "zozlak (19 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/zozlak-http-accept/health.svg)

```
[![Health](https://phpackages.com/badges/zozlak-http-accept/health.svg)](https://phpackages.com/packages/zozlak-http-accept)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
