Skip to content

codeinchq/http-reason-phrase-lookup

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

HTTP reason phrase lookup

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).