PHPackages                             gapple/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. gapple/structured-fields

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

gapple/structured-fields
========================

Library for Structured Field Values for HTTP

v2.3.3(2w ago)5708.7k↓31.8%[2 issues](https://github.com/gapple/structured-fields/issues)[1 PRs](https://github.com/gapple/structured-fields/pulls)MITPHPPHP ^8.1CI passing

Since Feb 1Pushed 2w ago1 watchersCompare

[ Source](https://github.com/gapple/structured-fields)[ Packagist](https://packagist.org/packages/gapple/structured-fields)[ GitHub Sponsors](https://github.com/gapple)[ Fund](https://ko-fi.com/gapple)[ RSS](/packages/gapple-structured-fields/feed)WikiDiscussions develop Synced yesterday

READMEChangelog (10)Dependencies (17)Versions (28)Used By (0)

Structured Field Values for PHP
===============================

[](#structured-field-values-for-php)

Parser and serializer for the [Structured Field Values for HTTP](https://www.rfc-editor.org/rfc/rfc9651.html) specification.

[![Build Status](https://github.com/gapple/structured-fields/actions/workflows/php.yml/badge.svg)](https://github.com/gapple/structured-fields/actions/workflows/php.yml)[![Code Coverage](https://camo.githubusercontent.com/aa8c7d513b42e89ee4743ebcdcfdb819fb269bcac6295767fb3fb5349ca76674/68747470733a2f2f636f6465636f762e696f2f67682f676170706c652f737472756374757265642d6669656c64732f6272616e63682f646576656c6f702f67726170682f62616467652e737667)](https://codecov.io/gh/gapple/structured-fields)[![Latest Release](https://camo.githubusercontent.com/bf6f9e66e7f4f9df8538d61e4c15e78caa21994de6d936e39dd4c86484113d36/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f72656c656173652f676170706c652f737472756374757265642d6669656c6473)](https://github.com/gapple/structured-fields/releases)[![Packagist Downloads](https://camo.githubusercontent.com/15e5b919364dee96e908395666d81e17bce22fbab6b5020a70c909f18c0ece62/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646d2f676170706c652f737472756374757265642d6669656c6473)](https://packagist.org/packages/gapple/structured-fields)

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

[](#installation)

Using composer:

```
composer require gapple/structured-fields

```

API
---

[](#api)

The `Parser` class provides static methods to convert a header string to structured data.
If the string cannot be parsed, a `ParseException` is thrown.

```
Parser::parseItem(string): Item;
Parser::parseList(string): OuterList;
Parser::parseDictionary(string): Dictionary;

```

The `Serializer` class provides static methods to convert structured data to a header string.
If the input cannot be serialized, a `SerializeException` is thrown.

```
Serializer::serializeItem(mixed, ?object): string;
Serializer::serializeList(iterable): string;
Serializer::serializeDictionary(object): string;

```

### Special Types

[](#special-types)

`Serializer` will accept `string` or any `Stringable` object as an Item value, but will throw a `SerializeException` if it contains any characters outside the printable ASCII range.

Special Item types must use a decorating class in order to be serialized correctly:

- **Byte Sequences** (`\gapple\StructuredFields\Bytes`)
    A string containing binary data.

    `Serializer` and `Parser` handle base64 encoding and decoding the provided string.
- **Display Strings** (`\gapple\StructuredFields\DisplayString`)
    A string that includes Unicode characters.

    `Serializer` and `Parser` handle percent-encoding and decoding non-ascii characters.
- **Tokens** (`\gapple\StructuredFields\Token`)
    A short textual word with a restricted character set.
- **Dates** (`\gapple\StructuredFields\Date`)
    An integer timestamp

    `Serializer` accepts any object that implements `\DateTimeInterface`.
    `Parser` will return a `\gapple\StructuredFields\Date` object.

###  Health Score

59

—

FairBetter than 98% of packages

Maintenance88

Actively maintained with recent releases

Popularity42

Moderate usage in the ecosystem

Community9

Small or concentrated contributor base

Maturity76

Established project with proven stability

 Bus Factor1

Top contributor holds 93.9% 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 ~96 days

Recently: every ~130 days

Total

25

Last Release

20d ago

Major Versions

v0.3.x-dev → v1.0.02021-06-18

v1.1.x-dev → v2.0.02023-02-10

PHP version history (4 changes)v0.1.0PHP ^7.2

v0.2.3PHP ^7.2 || ^8.0

v1.0.0PHP ^7.3 || ^8.0

v2.2.0PHP ^8.1

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/458809?v=4)[Geoff](/maintainers/gapple)[@gapple](https://github.com/gapple)

---

Top Contributors

[![gapple](https://avatars.githubusercontent.com/u/458809?v=4)](https://github.com/gapple "gapple (199 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (13 commits)")

---

Tags

httpphprfc8941rfc9651structured-fieldsstructured-headershttprfc8941rfc9651

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[guzzlehttp/psr7

PSR-7 message implementation that also provides common utility methods

8.0k1.1B4.0k](/packages/guzzlehttp-psr7)[psr/http-message

Common interface for HTTP messages

7.0k1.1B6.9k](/packages/psr-http-message)[psr/http-factory

PSR-17: Common interfaces for PSR-7 HTTP message factories

1.9k747.1M2.7k](/packages/psr-http-factory)[php-http/httplug

HTTPlug, the HTTP client abstraction for PHP

2.6k325.9M756](/packages/php-http-httplug)[psr/http-client

Common interface for HTTP clients

1.7k731.6M2.9k](/packages/psr-http-client)[symfony/http-client

Provides powerful methods to fetch HTTP resources synchronously or asynchronously

2.0k338.8M5.0k](/packages/symfony-http-client)

PHPackages © 2026

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