Download .zip |
Info | Documentation | View files (12) | Download .zip | Reputation | Support forum | Blog | Links |
Last Updated | Ratings | Unique User Downloads | Download Rankings | |||||
2017-12-12 (1 month ago) | Not enough user ratings | Total: 77 This week: 3 | All time: 8,972 This week: 175 |
Version | License | PHP version | Categories | |||
php-nano-http-status 1.0.1 | MIT/X Consortium ... | 7.0 | HTTP, PHP 7 |
Description | Author | |||
This package can process the HTTP request response status values. Innovation Award
|
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
Files |
File | Role | Description | ||
---|---|---|---|---|
src (2 files) | ||||
tests (1 file, 1 directory) | ||||
.travis.yml | Data | Auxiliary data | ||
CHANGELOG.md | Data | Auxiliary data | ||
composer.json | Data | Auxiliary data | ||
composer.lock | Data | Auxiliary data | ||
CONTRIBUTION.md | Data | Auxiliary data | ||
LICENSE | Lic. | License text | ||
phpunit.xml | Data | Auxiliary data | ||
README.md | Doc. | Documentation |
Files | / | src |
File | Role | Description |
---|---|---|
NanoHttpStatus.php | Class | Class source |
NanoHttpStatusInterface.php | Class | Class source |
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.