Skip to content

tiagohillebrandt/php-parse-link-header

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

tiagohillebrandt/php-parse-link-header

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
        )

)

About

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

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages