PHPackages                             graviton/link-header-rel-parser - 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. [API Development](/categories/api)
4. /
5. graviton/link-header-rel-parser

ActiveLibrary[API Development](/categories/api)

graviton/link-header-rel-parser
===============================

A small library that parses and generates RESTful Link headers with rel attributes (relations)

v1.0.1(3y ago)329.0k↓85.2%[1 issues](https://github.com/libgraviton/link-header-rel-parser/issues)3MITPHPPHP &gt;=7.2.0

Since Jun 21Pushed 3y ago1 watchersCompare

[ Source](https://github.com/libgraviton/link-header-rel-parser)[ Packagist](https://packagist.org/packages/graviton/link-header-rel-parser)[ RSS](/packages/graviton-link-header-rel-parser/feed)WikiDiscussions develop Synced yesterday

READMEChangelogDependencies (2)Versions (4)Used By (3)

graviton/link-header-rel-parser
===============================

[](#gravitonlink-header-rel-parser)

[![Build Status](https://camo.githubusercontent.com/43eb12085c4f77ca2113f3a4c97363e8ba5b65335fe0c8abbfa42ef584fac648/68747470733a2f2f7472617669732d63692e6f72672f6c69626772617669746f6e2f6c696e6b2d6865616465722d72656c2d7061727365722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/libgraviton/link-header-rel-parser) [![Latest Stable Version](https://camo.githubusercontent.com/589e047e51b5390252c614860986ee70d1af14decaa0063f0f308ad2b02623f9/68747470733a2f2f706f7365722e707567782e6f72672f6772617669746f6e2f6c696e6b2d6865616465722d72656c2d7061727365722f762f737461626c652e737667)](https://packagist.org/packages/graviton/link-header-rel-parser) [![Total Downloads](https://camo.githubusercontent.com/64cda16feba5128cadd0391998d33a3cc1592a7628005b14ff97d07626362bdc/68747470733a2f2f706f7365722e707567782e6f72672f6772617669746f6e2f6c696e6b2d6865616465722d72656c2d7061727365722f646f776e6c6f6164732e737667)](https://packagist.org/packages/graviton/link-header-rel-parser) [![License](https://camo.githubusercontent.com/7cef2aca7f04d5fb745e145208b2773504ad0e841b9a9384a7819f7de1d344eb/68747470733a2f2f706f7365722e707567782e6f72672f6772617669746f6e2f6c696e6b2d6865616465722d72656c2d7061727365722f6c6963656e73652e737667)](https://packagist.org/packages/graviton/link-header-rel-parser)

This is a small standalone PHP library that helps with parsing *and creating* `Link` header contents with `rel=""` attributes as it is used in the context of RESTful web services.

It is a tolerant parser, silently accepting invalid input. You can use the API functions to check if a given `rel` exists.

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

[](#installation)

The preferred way to install library is through [composer](http://getcomposer.org/download/).

Either run

```
composer require graviton/link-header-rel-parser

```

or add

```
"graviton/link-header-rel-parser": "*",
```

to the require section of your `composer.json`.

Examples
--------

[](#examples)

### Parsing headers

[](#parsing-headers)

Parsing an existing header is easy, just pass the plain header *contents* to the static function:

```
$header = '; rel="self", '; rel="next"';
$linkHeader = LinkHeader::fromString($header);

$selfUrl = $linkHeader->getRel('self')->getUri(); // will output 'http://localhost/service/self'
```

If you are using Symfony, just fetch the Link header from the `Request` or `Response` object and pass it to the library.

### Creating headers

[](#creating-headers)

You can create header contents programmatically:

```
$header = new LinkHeader();
$header->add(new LinkHeaderItem('http://localhost?limit(10,10)', 'self'));
$header->add(new LinkHeaderItem('http://localhost?limit(10,30)', 'next'));
$header->add(new LinkHeaderItem('http://localhost?limit(10,0)', 'prev'));

echo (string) $header;
```

Will produce

```
; rel="self", ; rel="next", ; rel="prev"

```

### Manipulating existing

[](#manipulating-existing)

Combining both methods above, you can also parse existing headers, manipulate them and render them.

```
$header = '; rel="self", '; rel="next"';
$linkHeader = LinkHeader::fromString($header);

$linkHeader->add(new LinkHeaderItem('http://localhost?limit(10,10)', 'prev'));
$linkHeader->removeRel('next');
$header->getRel('self')->setUri('http://newhost');

echo (string) $header;
```

Will produce

```
; rel="self", ; rel="prev"

```

###  Health Score

30

—

LowBetter than 62% of packages

Maintenance13

Infrequent updates — may be unmaintained

Popularity27

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

 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 ~1210 days

Total

2

Last Release

1358d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/245441?v=4)[Dario Nuevo](/maintainers/narcoticfresh)[@narcoticfresh](https://github.com/narcoticfresh)

---

Top Contributors

[![narcoticfresh](https://avatars.githubusercontent.com/u/245441?v=4)](https://github.com/narcoticfresh "narcoticfresh (7 commits)")

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/graviton-link-header-rel-parser/health.svg)

```
[![Health](https://phpackages.com/badges/graviton-link-header-rel-parser/health.svg)](https://phpackages.com/packages/graviton-link-header-rel-parser)
```

###  Alternatives

[exsyst/swagger

A php library to manipulate Swagger specifications

35916.4M7](/packages/exsyst-swagger)[hubspot/api-client

Hubspot API client

24016.2M20](/packages/hubspot-api-client)[pocketmine/bedrock-protocol

An implementation of the Minecraft: Bedrock Edition protocol in PHP

172445.0k15](/packages/pocketmine-bedrock-protocol)[botman/driver-telegram

Telegram driver for BotMan

93459.5k6](/packages/botman-driver-telegram)

PHPackages © 2026

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