承接 intenave/http-response-status-codes 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

intenave/http-response-status-codes

最新稳定版本:v1.0.0

Composer 安装命令:

composer require intenave/http-response-status-codes

包简介

Package provides an enumeration of standard HTTP status codes along with convenient methods for working with them.

README 文档

README

Description

The HttpResponseStatusCode PHP package is a utility for managing HTTP response status codes. It provides an enumeration of standard HTTP status codes along with convenient methods for working with them.

Features

  • Enumerates standard HTTP response status codes with both their names and values.
  • Provides methods to retrieve codes, names, and options for HTTP status codes.
  • Offers methods to check if a given code is a success (in the 200-299 range).

Installation

You can install this package via Composer:

composer require intenave/http-response-status-codes

Usage

Using the HttpResponseStatusCode package is straightforward. You can access the predefined HTTP status codes, check for success, and retrieve code information as needed.

Getting a Specific Status Code

You can easily obtain a specific HTTP status code using the package:

$status = HttpResponseStatusCode::OK(); // Get the "OK" (200) status code

Checking if a Code is a Success

You can use the isSuccess() method to check if a code is a success (in the 200-299 range):

$isSuccess = $status->isSuccess(); // Check if it's a success code (in the 200-299 range)

if ($isSuccess) {
    // Handle a successful response.
} else {
    // Handle a non-successful response.
}

Retrieving Codes, Names, and Options

You can also retrieve information about the available status codes:

  • To get an array of all status codes (values only):
$codes = HttpResponseStatusCode::codes();
  • To get an array of all status code names:
$names = HttpResponseStatusCode::names();
  • To get an associative array of code names and values:
$options = HttpResponseStatusCode::options();

These methods provide flexibility and ease of use when working with HTTP status codes in your PHP applications.

Contributing

This package is maintained under the Intenave organization. If you'd like to contribute or report issues, please visit the GitHub repository.

License

This package is open-source and available under the MIT License. See the LICENSE file for more information.

统计信息

  • 总下载量: 44
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-10-20