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.2(1y ago)4630.9k—2.7%[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 1mo 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 1mo ago

READMEChangelog (10)Dependencies (8)Versions (27)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

52

—

FairBetter than 96% of packages

Maintenance61

Regular maintenance activity

Popularity41

Moderate usage in the ecosystem

Community9

Small or concentrated contributor base

Maturity76

Established project with proven stability

 Bus Factor1

Top contributor holds 94.3% 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 ~82 days

Recently: every ~48 days

Total

24

Last Release

399d 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://www.gravatar.com/avatar/5fa5fef80c017296f62b735d5901c889fe7fa0224c162d1eadfc9f4d40a5b97e?d=identicon)[gapple](/maintainers/gapple)

---

Top Contributors

[![gapple](https://avatars.githubusercontent.com/u/458809?v=4)](https://github.com/gapple "gapple (198 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (12 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.0B3.2k](/packages/guzzlehttp-psr7)[psr/http-message

Common interface for HTTP messages

7.1k1.0B5.5k](/packages/psr-http-message)[psr/http-factory

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

1.9k692.9M1.9k](/packages/psr-http-factory)[php-http/httplug

HTTPlug, the HTTP client abstraction for PHP

2.6k307.6M679](/packages/php-http-httplug)[psr/http-client

Common interface for HTTP clients

1.7k680.7M2.1k](/packages/psr-http-client)[symfony/http-client

Provides powerful methods to fetch HTTP resources synchronously or asynchronously

2.0k314.0M3.4k](/packages/symfony-http-client)

PHPackages © 2026

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