| Recommend this page to a friend! |
| Info | Documentation | Reputation | Support forum | Blog | Links |
| Ratings | Unique User Downloads | Download Rankings | ||||
| Not enough user ratings | Total: 189 | All time: 8,608 This week: 673 | ||||
| Version | License | PHP version | Categories | |||
| php-nano-http-status 1.0.1 | MIT/X Consortium ... | 7.0 | HTTP, PHP 7 |
Truly minimalistic and self-contained package to handle HTTP statuses and relevant description messages. Such packages as Teapot or Httpstatus are nice and famous, but still either too heavy and over-complicated or simply does not fit to Gino Pane's high code quality standards.
composer require gino-pane/nano-http-status
Check existence of the code (using numeric codes or nice readable constants):
(new NanoHttpStatus())->statusExists(200); //true
(new NanoHttpStatus())->statusExists(400); //true
(new NanoHttpStatus())->statusExists(451); //true
(new NanoHttpStatus())->statusExists(511); //true
(new NanoHttpStatus())->statusExists(522); //false
Detect the class of the code using code numbers:
(new NanoHttpStatus())->isInformational(NanoHttpStatus::HTTP_OK); //false
(new NanoHttpStatus())->isSuccess(202); //true
(new NanoHttpStatus())->isRedirection(301); //true
(new NanoHttpStatus())->isClientError(404); //true
(new NanoHttpStatus())->isServerError(NanoHttpStatus::HTTP_BAD_REQUEST); //false
Get status message by status code:
(new NanoHttpStatus())->getMessage(200); //OK
(new NanoHttpStatus())->getMessage(451); //Unavailable For Legal Reasons
(new NanoHttpStatus())->getMessage(452); //Undefined Status
Set localization mapping and get custom status messages:
$status = new NanoHttpStatus([
NanoHttpStatus::HTTP_BAD_REQUEST => 'Very bad request',
NanoHttpStatus::HTTP_BAD_GATEWAY => 'Not so bad gateway'
]);
$status->getMessage(400); //'Very bad request'
$status->getMessage(502); //'Not so bad gateway'
Please note, that `NanoHttpStatus` itself does not throw any exceptions for invalid statuses.
php vendor/bin/phpunit
or
composer test
php vendor/bin/phpcs --standard=PSR2 src/
or
composer psr2check
php vendor/bin/phpcbf --standard=PSR2 src/
or
composer psr2autofix
php vendor/bin/phpdoc -d "src" -t "docs"
or
composer docs
To keep track, please refer to CHANGELOG.md.
Also please refer to CONTRIBUTION.md.
Please refer to LICENSE.
Powered by composer-package-template
| File | Role | Description | ||
|---|---|---|---|---|
| Data | Auxiliary data | |||
| Data | Auxiliary data | |||
| Data | Auxiliary data | |||
| Data | Auxiliary data | |||
| Data | Auxiliary data | |||
| Lic. | License text | |||
| Data | Auxiliary data | |||
| Doc. | Documentation | |||
| / | src |
| File | Role | Description |
|---|---|---|
| |
Class | Class source |
| |
Class | Class source |
| The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page. |
| php-nano-http-status-2017-12-12.zip 28KB | |
| php-nano-http-status-2017-12-12.tar.gz 26KB | |
| Install with Composer |
| Version Control | Unique User Downloads | Download Rankings | |||||||||||||||
| 100% |
|
|
| Applications that use this package |
If you know an application of this package, send a message to the author to add a link here.