tiagohillebrandt/php-parse-link-header

Parses the Link HTTP header and returns the values as an array.

Maintainers

👁 tiagohillebrandt

Package info

github.com/tiagohillebrandt/php-parse-link-header

pkg:composer/tiagohillebrandt/php-parse-link-header

Statistics

Installs: 59 254

Dependents: 1

Suggesters: 0

Stars: 7

Open Issues: 0

1.0.4 2020-04-15 22:58 UTC

Requires

  • php: >=7.2

Requires (Dev)

None

Suggests

None

Provides

None

Conflicts

None

Replaces

None

MIT f59cefc8b8a17e0887c0bc36aafaaa1d1fe47b9d

githubparselinkheader

This package is auto-updated.

Last update: 2026-06-16 13:10:32 UTC


README

Parse the HTTP Link header and return the values as an array.

Installation with Composer

$ composer require tiagohillebrandt/php-parse-link-header

Usage

$headers = [
 'Link' => '<https://api.github.com/organizations/xyz/repos?page=2>; rel="next", <https://api.github.com/organizations/xyz/repos?page=4>; rel="last"',
];

$links = ( new TiagoHillebrandt\ParseLinkHeader( $headers['Link'] ) )->toArray();

print_r( $links );

The above example will output:

Array
(
 [next] => Array
 (
 [link] => https://api.github.com/organizations/xyz/repos?page=2
 [page] => 2
 )

 [last] => Array
 (
 [link] => https://api.github.com/organizations/xyz/repos?page=4
 [page] => 4
 )

)