PHPackages                             bakame/http-structured-fields - 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. [HTTP &amp; Networking](/categories/http)
4. /
5. bakame/http-structured-fields

ActiveLibrary[HTTP &amp; Networking](/categories/http)

bakame/http-structured-fields
=============================

A PHP library that parses, validates and serializes HTTP structured fields according to RFC9561 and RFC8941

2.0.0(1y ago)442.6k—3.8%34MITPHPPHP ^8.1CI passing

Since Mar 18Pushed 6mo ago1 watchersCompare

[ Source](https://github.com/bakame-php/http-structured-fields)[ Packagist](https://packagist.org/packages/bakame/http-structured-fields)[ GitHub Sponsors](https://github.com/sponsors/nyamsprod)[ RSS](/packages/bakame-http-structured-fields/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (10)Versions (18)Used By (4)

[![HTTPsf](.github/httpsf-logo.png?raw=true)](.github/httpsf-logo.png?raw=true)

HTTP Structured Fields for PHP
==============================

[](#http-structured-fields-for-php)

[![Author](https://camo.githubusercontent.com/8227017ba73e8c0c93fa2c9c653cf702644a5af5d422e7f612b31d45efc180a1/687474703a2f2f696d672e736869656c64732e696f2f62616467652f617574686f722d406e79616d7370726f642d626c75652e7376673f7374796c653d666c61742d737175617265)](https://twitter.com/nyamsprod)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE)[![Build](https://github.com/bakame-php/http-structured-fields/workflows/build/badge.svg)](https://github.com/bakame-php/http-structured-fields/actions?query=workflow%3A%22build%22)[![Latest Version](https://camo.githubusercontent.com/573d72dd6fcdaff3b8f701baac4fc43e4521e61f7cd0e5b41b9c3c613ef2b572/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f62616b616d652d7068702f687474702d737472756374757265642d6669656c64732e7376673f7374796c653d666c61742d737175617265)](https://github.com/bakame-php/http-structured-fields/releases)[![Total Downloads](https://camo.githubusercontent.com/e765590b84b7c1cc86aa25348f1a5c4761a90d052ea43f8653857d2b44e82bc3/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f62616b616d652f687474702d737472756374757265642d6669656c64732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/bakame/http-structured-fields)[![Sponsor development of this project](https://camo.githubusercontent.com/2e662697b46a37233abdd7e45373397aab0bd5206336533151cdf42455d81048/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f73706f6e736f72253230746869732532307061636b6167652d2545322539442541342d6666363962342e7376673f7374796c653d666c61742d737175617265)](https://github.com/sponsors/nyamsprod)

`bakame/http-structured-fields` is a framework-agnostic PHP library that allows you to parse, serialize, create, update and validate HTTP Structured Fields in PHP according to the [RFC9651](https://www.rfc-editor.org/rfc/rfc9651.html).

Once installed you will be able to do the following:

```
use Bakame\Http\StructuredFields\OuterList;

//1 - parsing an Accept Header
$fieldValue = 'text/html, application/xhtml+xml, application/xml;q=0.9, image/webp, */*;q=0.8';
$container = OuterList::fromRfc9651($fieldValue);
$container[1]->value()->toString(); // returns 'application/xhtml+xml'
$container[1]->parameterByKey(key: 'q', default: 1.0); // returns 1.0 if the parameter is not defined

```

System Requirements
-------------------

[](#system-requirements)

**PHP &gt;= 8.1** is required but the latest stable version of PHP is recommended.

Installation
------------

[](#installation)

Use composer:

```
composer require bakame/http-structured-fields

```

Documentation
-------------

[](#documentation)

Full documentation can be found at [https://bakame-php.github.io/http-structured-fields](//bakame-php.github.io/http-structured-fields)

Contributing
------------

[](#contributing)

Contributions are welcome and will be fully credited. Please see [CONTRIBUTING](.github/CONTRIBUTING.md) and [CODE OF CONDUCT](.github/CODE_OF_CONDUCT.md) for details.

Testing
-------

[](#testing)

The library:

- has a [PHPUnit](https://phpunit.de) test suite
- has a coding style compliance test suite using [PHP CS Fixer](https://cs.sensiolabs.org/).
- has a code analysis compliance test suite using [PHPStan](https://github.com/phpstan/phpstan).
- is compliant with [the language agnostic HTTP Structured Fields Test suite](https://github.com/httpwg/structured-field-tests).

To run the tests, run the following command from the project folder.

```
composer test

```

Security
--------

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [ignace nyamagana butera](https://github.com/nyamsprod)
- [All Contributors](https://github.com/bakame-php/http-structured-fields/contributors)

Attribution
-----------

[](#attribution)

The package internal parser is heavily inspired by previous work done by [Gapple](https://twitter.com/gappleca) on [Structured Field Values for PHP](https://github.com/gapple/structured-fields/).

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE) for more information.

###  Health Score

47

—

FairBetter than 94% of packages

Maintenance55

Moderate activity, may be stable

Popularity35

Limited adoption so far

Community19

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor1

Top contributor holds 99.4% 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 ~62 days

Recently: every ~86 days

Total

17

Last Release

523d ago

Major Versions

0.8.0 → 1.0.02023-04-16

1.x-dev → 2.0.02024-12-12

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/51073?v=4)[Ignace Nyamagana Butera](/maintainers/nyamsprod)[@nyamsprod](https://github.com/nyamsprod)

---

Top Contributors

[![nyamsprod](https://avatars.githubusercontent.com/u/51073?v=4)](https://github.com/nyamsprod "nyamsprod (485 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (1 commits)")[![k00ni](https://avatars.githubusercontent.com/u/381727?v=4)](https://github.com/k00ni "k00ni (1 commits)")[![WyriHaximus](https://avatars.githubusercontent.com/u/147145?v=4)](https://github.com/WyriHaximus "WyriHaximus (1 commits)")

---

Tags

httphttp-headersparse-headersphprfcrfc8941rfc9651structured-fieldsstructured-headersstructured-trailershttpvalidationparserserializerheadershttp-headersrfc8941rfc9651http trailerstrailersstructured fieldsstructured headersstructured trailersstructured values

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/bakame-http-structured-fields/health.svg)

```
[![Health](https://phpackages.com/badges/bakame-http-structured-fields/health.svg)](https://phpackages.com/packages/bakame-http-structured-fields)
```

###  Alternatives

[league/openapi-psr7-validator

Validate PSR-7 messages against OpenAPI (3.0.2) specifications expressed in YAML or JSON

55715.9M69](/packages/league-openapi-psr7-validator)[mimmi20/browser-detector

Library to detect Browsers and Devices

48153.5k3](/packages/mimmi20-browser-detector)[synchro/uasparser

UASparser is a PHP parser and classifier for user agent strings presented by HTTP clients using databases from http://user-agent-string.info/.

2016.5k](/packages/synchro-uasparser)

PHPackages © 2026

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