webservco / http-response-service
A PHP component/library. List of HTTP status codes, with a validator for them.
Package info
github.com/webservco/http-response-service
pkg:composer/webservco/http-response-service
v2.3.0
2026-10-11 16:34 UTC
Requires
- php: ^8.4
- fig/http-message-util: ^1
Requires (Dev)
- pds/skeleton: ^1
- phan/phan: ^6
- php-parallel-lint/php-console-highlighter: ^1
- php-parallel-lint/php-parallel-lint: ^1
- phpmd/phpmd: ^3
- phpstan/phpstan: ^2
- phpstan/phpstan-deprecation-rules: ^2
- phpstan/phpstan-phpunit: ^2
- phpstan/phpstan-strict-rules: ^2
- phpunit/phpunit: ^13
- slevomat/coding-standard: ^8
- squizlabs/php_codesniffer: ^4
- vimeo/psalm: ^6
- webservco/coding-standards: ^2
- webservco/component-common: ^2
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
A PHP component/library. Please see webservco/sandbox for an example project using these types of components.
List of HTTP status codes, with a validator for them.
- Related:
webservco/http(Responsevalidates its status code with this),webservco/dependency-container(getResponseServiceContainer())
Installation
composer require webservco/http-response-service
Usage
use WebServCo\Http\Contract\Message\Response\StatusCodeServiceInterface; use WebServCo\Http\Service\Message\Response\StatusCodeService; // \WebServCo\Http\Contract\Message\Response\StatusCodeServiceInterface $statusCodeService = new StatusCodeService(); // Throws for a code that isn't in the list. $statusCodeService->validateStatusCode($code); $isRedirect = array_key_exists($code, StatusCodeServiceInterface::REDIRECT_STATUS_CODES);
The interface extends Fig\Http\Message\StatusCodeInterface. Constants like STATUS_NOT_FOUND are available through it.
Contracts
| Interface | Implementation | Purpose |
|---|---|---|
Contract\Message\Response\StatusCodeServiceInterface |
Service\Message\Response\StatusCodeService |
STATUS_CODES and REDIRECT_STATUS_CODES lists, and validateStatusCode(). |
Contract\Message\Response\Container\ResponseServiceContainerInterface |
Container\Message\Response\ResponseServiceContainer |
Gives access to the status code service. |
Namespaces are relative to WebServCo\Http\.
Development
# Start project. ddev start # Install dependencies. ddev c u # Run all validations. ddev c c # Run unit tests. ddev c test:dox