nullform/http-status
Composer 安装命令:
composer require nullform/http-status
包简介
HTTP status codes as constants
README 文档
README
HTTP status codes as constants in one simple class.
Installation
composer require nullform/http-status
Usage
use Nullform\HttpStatus; // some code... if ($response->getStatusCode() == HttpStatus::OK) { // some code... } else { $error = HttpStatus::getDescription($response->getStatusCode()); }
HttpStatus constants
- HttpStatus::CONTINUE
- HttpStatus::SWITCHING_PROTOCOLS
- HttpStatus::OK
- HttpStatus::CREATED
- HttpStatus::ACCEPTED
- HttpStatus::NON_AUTHORITATIVE_INFORMATION
- HttpStatus::NO_CONTENT
- HttpStatus::RESET_CONTENT
- HttpStatus::PARTIAL_CONTENT
- HttpStatus::MULTIPLE_CHOICES
- HttpStatus::MOVED_PERMANENTLY
- HttpStatus::FOUND
- HttpStatus::SEE_OTHER
- HttpStatus::NOT_MODIFIED
- HttpStatus::USE_PROXY
- HttpStatus::TEMPORARY_REDIRECT
- HttpStatus::PERMANENT_REDIRECT
- HttpStatus::BAD_REQUEST
- HttpStatus::UNAUTHORIZED
- HttpStatus::PAYMENT_REQUIRED
- HttpStatus::FORBIDDEN
- HttpStatus::NOT_FOUND
- HttpStatus::METHOD_NOT_ALLOWED
- HttpStatus::NOT_ACCEPTABLE
- HttpStatus::PROXY_AUTHENTICATION_REQUIRED
- HttpStatus::REQUEST_TIMEOUT
- HttpStatus::CONFLICT
- HttpStatus::GONE
- HttpStatus::LENGTH_REQUIRED
- HttpStatus::PRECONDITION_FAILED
- HttpStatus::CONTENT_TOO_LARGE
- HttpStatus::URI_TOO_LONG
- HttpStatus::UNSUPPORTED_MEDIA_TYPE
- HttpStatus::RANGE_NOT_SATISFIABLE
- HttpStatus::EXPECTATION_FAILED
- HttpStatus::MISDIRECTED_REQUEST
- HttpStatus::UNPROCESSABLE_CONTENT
- HttpStatus::UPGRADE_REQUIRED
- HttpStatus::PRECONDITION_REQUIRED
- HttpStatus::TOO_MANY_REQUESTS
- HttpStatus::REQUEST_HEADER_FIELDS_TOO_LARGE
- HttpStatus::INTERNAL_SERVER_ERROR
- HttpStatus::NOT_IMPLEMENTED
- HttpStatus::BAD_GATEWAY
- HttpStatus::SERVICE_UNAVAILABLE
- HttpStatus::GATEWAY_TIMEOUT
- HttpStatus::HTTP_VERSION_NOT_SUPPORTED
- HttpStatus::NETWORK_AUTHENTICATION_REQUIRED
HttpStatus methods
HttpStatus::isInformational(int $status): bool
The request was received, continuing process.
HttpStatus::isSuccessful(int $status): bool
The request was successfully received, understood, and accepted.
HttpStatus::isRedirection(int $status): bool
Further action needs to be taken in order to complete the request.
HttpStatus::isClientError(int $status): bool
The request contains bad syntax or cannot be fulfilled.
HttpStatus::isServerError(int $status): bool
The server failed to fulfill an apparently valid request.
HttpStatus::getReason(int $status): string
HTTP status reason phrase.
HttpStatus::getDescription(int $status): string
HTTP status description.
HttpStatus::getAllReasons(): string[]
All HTTP status codes (array keys) with reason phrases (array values).
HttpStatus::getAllDescriptions(): string[]
All HTTP status codes (array keys) with status descriptions (array values).
HttpStatusCode class
You can use the HttpStatusCode class to represent any HTTP status code.
Example:
use Nullform\HttpStatusCode; // some code... $status = new HttpStatusCode($response->getStatusCode()); if ($status->isSuccessful()) { // some code... } else { throw new \Exception($status->getReason() . '. ' . $status->getDescription()); }
nullform/http-status 适用场景与选型建议
nullform/http-status 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 3.3k 次下载、GitHub Stars 达 2, 最近一次更新时间为 2019 年 03 月 18 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「http」 「codes」 「status」 「http status」 「status codes」 「rfc9110」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 nullform/http-status 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 nullform/http-status 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 nullform/http-status 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Serves functionality of healthchecks of your application
repository php library
Doctrine implementation of the MetaborStd (Statemachine) for PHP 8.2+
ZipField is a form field for entering and validating postal codes in ATK14 applications
404 'not found' and 403 'forbidden' error handlers. The 404 handler shows custom content for missing pages but not resources like CSS or JS. The 403 handler redirects to a login URL on unauthorized access.
Provide status and health api endpoints
统计信息
- 总下载量: 3.3k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 20
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-03-18