定制 femastudios/http-utils 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

femastudios/http-utils

Composer 安装命令:

composer require femastudios/http-utils

包简介

PHP collection of enums and basic utilities for HTTP

README 文档

README

This library is a very simple collection of a few classes to facilitate handling HTTP requests.

Installation

Available as composer package femastudios/http-utils. PHP 7.3 or greater required.

Contents & Usage

Core

Very base classes. Enumerators are declared using the femastudios/enums library.

  • HttpRequestMethod: enumerator that defines the common request methods (GET, POST, etc.). They also have some properties (e.g. is cachable)
  • HttpResponseCode: enumerator that defines the common response codes (SUCCESS, NOT_FOUND, FORBIDDEN, etc.). They have the numerical code and the standard message.
  • HttpResponseCodeType: enumerator that defines the type of a response code (i.e. INFORMATIONAL, SUCCESSFUL, REDIRECTION, CLIENT_ERROR and SERVER_ERROR)
  • HttpException: exception class that wraps an HttpResponseCode enum, useful to bubble up an HTTP response code that need to be handled at a higher level.

Header utils

These utilities allow to better handle request and response HTTP headers.

  • RequestHeaderUtils: contains functions to read the headers sent by the requester (even in a context that does not define getallheaders(), like FPM).
  • ResponseHeaderUtils: contains functions to add and read headers to be sent, also with support of comma-separated values (that can be added in different calls).

Example usage:

RequestHeaderUtils::get('Content-Type', 'none'); // Get the header, or default value

ResponseHeaderUtils::put('Content-Type', 'application/json'); // Put the header or throws if they have already been sent
ResponseHeaderUtils::addCsv('Vary', 'Origin'); // Treats the header value as a comma-separated value and adds "Origin"

Uploaded files utils

Here we have utilities that help handling file uploads. The main reason for this utility is:

  1. Handle the errors with an exception;
  2. Untangle the mess that is the $_FILES array when the param name is nested (e.g. user[info][avatar]). For more on this see the doc of UploadedFilesUtils::getReorderedFiles().

The classes are:

  • UploadedFile: class that contains the info on a single uploaded file (e.g. name, size, etc.)
  • UploadedFileException: exception thrown when an error uploading a file is detected. It cotains the error code and a description of the error as message.
  • UploadedFilesUtils: contains static functions to retrieve the uploaded files

Example usage:

$uf = UploadedFilesUtils::getUploadedFile('user', 'info', 'avatar'); // Returns an UploadedFile or throws UploadedFileException
$uf->getTmpName(); // Return the file temp filename (e.g. /tmp/php1324.tmp)

femastudios/http-utils 适用场景与选型建议

femastudios/http-utils 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 86 次下载、GitHub Stars 达 0, 最近一次更新时间为 2020 年 07 月 08 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: GPL-3.0-only
  • 更新时间: 2020-07-08