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)328.4k↓22.7%[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 1mo ago

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

31

—

LowBetter than 68% of packages

Maintenance13

Infrequent updates — may be unmaintained

Popularity30

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

1313d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/3b067c41ace2e4fdefbc4ed805fd9cca69c6bb1cec6d2f743b5c8ed2f3dbf713?d=identicon)[narcoticfresh](/maintainers/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

[stripe/stripe-php

Stripe PHP Library

4.0k143.3M480](/packages/stripe-stripe-php)[twilio/sdk

A PHP wrapper for Twilio's API

1.6k92.9M272](/packages/twilio-sdk)[facebook/php-business-sdk

PHP SDK for Facebook Business

90821.9M34](/packages/facebook-php-business-sdk)[meilisearch/meilisearch-php

PHP wrapper for the Meilisearch API

74513.7M114](/packages/meilisearch-meilisearch-php)[google/gax

Google API Core for PHP

265103.1M454](/packages/google-gax)[google/common-protos

Google API Common Protos for PHP

173103.7M50](/packages/google-common-protos)

PHPackages © 2026

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