mrcl / http-status-codes
HTTP Status Codes library
Installs: 8
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/mrcl/http-status-codes
Requires
- php: >=7.4
Requires (Dev)
- phpunit/phpunit: ^9.5
README
PHP library containing all status codes and their corresponding messages listed in the IANA registry plus 418 I'm a teapot.
Installation
composer require mrcl/http-status-codes
Usage
HttpStatus
use Mrcl\Utils\InternetStandards\HttpStatus;
The HttpStatus
class implements all status codes as constants
HttpStatus::OK // 200 HttpStatus::NOT_FOUND // 404
Additionally, you can retrieve the corresponding status message
HttpStatus::MESSAGES[200] // 'OK' HttpStatus::MESSAGES[HttpStatus::NOT_FOUND] // 'Not Found'
Interfaces
Every status category has its own interface containing the associated codes as constants
1xx Informational
use Mrcl\Utils\InternetStandards\HttpStatusCodes\Informational; Informational::CONTINUE // 100
2xx Success
use Mrcl\Utils\InternetStandards\HttpStatusCodes\Success; Success::ACCEPTED // 202
3xx Redirection
use Mrcl\Utils\InternetStandards\HttpStatusCodes\Redirection; Redirection::MOVED_PERMANENTLY // 301
4xx ClientError
use Mrcl\Utils\InternetStandards\HttpStatusCodes\ClientError; ClientError::BAD_REQUEST // 400
5xx ServerError
use Mrcl\Utils\InternetStandards\HttpStatusCodes\ServerError; ServerError::NETWORK_AUTHENTICATION_REQUIRED // 511