codeinc/http-reason-phrase-lookup

A class to lookup HTTP reason phrases

1.0.0 2018-06-12 11:08 UTC

This package is auto-updated.

Last update: 2024-10-25 07:42:05 UTC


README

This library is a PHP 7.1 library dedicated to lookup HTTP reason phrases. It is using the reason phrases list from the Guzzle PSR-7 package.

Usage

<?php
use CodeInc\Psr7ResponseSender\HttpReasonPhraseLookup;

// you can lookup a given status code 
HttpReasonPhraseLookup::getReasonPhrase(404); // returns 'Not Found'
HttpReasonPhraseLookup::getReasonPhrase(999); // returns null

// or list all the reason phrases
foreach (HttpReasonPhraseLookup::getReasonPhrases() as $statusCode => $reasonPhrase) {
    echo "$statusCode => $reasonPhrase\n";
}

Installation

This library is available through Packagist and can be installed using Composer:

composer require codeinc/http-reason-phrase-lookup

License

This library is published under the MIT license (see the LICENSE file).