承接 alexanderpas/http-enum 相关项目开发

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

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

alexanderpas/http-enum

Composer 安装命令:

composer require alexanderpas/http-enum

包简介

README 文档

README

PHP Version Require Latest Stable Version Latest Unstable Version License

This package provides HTTP Methods, Status Codes and Reason Phrases as PHP 8.1+ enums

All IANA registered HTTP Status codes and corresponding Reason Phrases as of the latest update on 2018-09-21 are supported.

This includes the HTTP Methods defined in RFC 5789 and RFC 7231, as well as all Status Codes and Reason Phrases as defined in HTTP/1.1 (RFC 7231, RFC 7232, RFC 7233, RFC 7235) and HTTP/2 (RFC 7540) as well as other RFC's defining HTTP status codes such as WebDAV (RFC 2518, RFC 4918, RFC 5842, RFC 8144) and more (RFC 8297, RFC 3229, RFC 7538, RFC 7694, RFC 6585, RFC 7725, RFC 2295, RFC 2774)

Requirements

  • PHP 8.1 or above

Installation

Composer:

composer require alexanderpas/http-enum

Manually (Without Composer):

include the src/Method.php file in order to use the HTTP methods enum.

include both the src/ReasonPhrase.php file as well as the src/StatusCode.php file in order to use the HTTP Status Code enum or the HTTP Reason Phrase enum.

Available Enums and Enum methods

All available Enums live in the \Alexanderpas\Common\HTTP namespace.

  • HTTP Methods are represented by the \Alexanderpas\Common\HTTP\Method enum.
  • HTTP Status Codes are represented by the \Alexanderpas\Common\HTTP\StatusCode enum.
  • HTTP Reason Phrases are represented by the \Alexanderpas\Common\HTTP\ReasonPhrase enum.

In addition to the Enum methods available by default on Backed Enums, the following Enum methods are available.

  • Method::fromName(string $name): Method Gives back a HTTP method enum when provided with a valid HTTP method. (such as 'GET' or 'POST' or 'put' or 'pAtcH')
  • StatusCode::fromInteger(int $integer): StatusCode Gives back a HTTP Status Code enum when provided with a valid HTTP status code as integer. (such as 200 or 404)
  • StatusCode::fromName(string $name): StatusCode Gives back a HTTP Status Code enum when provided with a valid HTTP status code as a HTTP_ prefixed string. (such as 'HTTP_200' or 'HTTP_404')
  • ReasonPhrase::fromInteger(int $integer): ReasonPhrase Gives back a HTTP Reason Phrase enum when provided with a valid HTTP status code as integer. (such as 200 or 404)
  • ReasonPhrase::fromName(string $name): ReasonPhrase Gives back a HTTP Reason Phrase enum when provided with a valid HTTP status code as a HTTP_ prefixed string. (such as 'HTTP_200' or 'HTTP_404')

All of the above methods also have a try variant (such as Method::tryFromName(?string $name): ?Method), which returns null if an invalid value of the correct type has been given instead of throwing an exception.

Additionally, you can change between Status Code enums and Reason Phrase enums using the following methods:

  • ReasonPhrase::fromStatusCode(StatusCode $statusCode): ReasonPhrase changes a Status Code enum into the corresponding Reason Phrase enum.
  • StatusCode::fromReasonPhrase(ReasonPhrase $reasonPhrase): StatusCode changes a Reason Phrase enum into the corresponding Status Code enum.

These methods do not have a try variant.

You can get the respective string or integer representation as usual by reading the value attribute on the enum.

License

Copyright Alexander Pas 2021. Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)

Notes

alexanderpas/http-enum 适用场景与选型建议

alexanderpas/http-enum 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 142.84k 次下载、GitHub Stars 达 81, 最近一次更新时间为 2021 年 09 月 20 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 alexanderpas/http-enum 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 alexanderpas/http-enum 我们能提供哪些服务?
定制开发 / 二次开发

基于 alexanderpas/http-enum 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 142.84k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 82
  • 点击次数: 6
  • 依赖项目数: 4
  • 推荐数: 0

GitHub 信息

  • Stars: 81
  • Watchers: 2
  • Forks: 5
  • 开发语言: PHP

其他信息

  • 授权协议: BSL-1.0
  • 更新时间: 2021-09-20