link1515/http-utils-php5 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

link1515/http-utils-php5

Composer 安装命令:

composer require link1515/http-utils-php5

包简介

For users working with PHP 5.x environments, this package provides a convenient solution. It provides encapsulated utilities for handling requests and responses.

README 文档

README

For users working with PHP 5.x environments, this package provides a convenient solution. It provides encapsulated utilities for handling requests and responses.

Feature

  • Easy to use
  • Compatible with PHP 5.x
  • The request body of the PUT and PATCH method can be resolved (including multipart/form-data)

Installation

composer require link1515/http-utils-php5

Usage

Request

Return type Method
string getIp()
string getHost()
string getMethod()
array getHeaders(?string $dotNotation = null)
array|string getCookies(?string $dotNotation = null)
array|string getQueryString(?string $dotNotation = null)
array|string|null getBody(?string $dotNotation = null)
array|null getFiles(?string $dotNotation = null)
array toArray()
<?php

require_once __DIR__ . '/../vendor/autoload.php';

use Link1515\HttpUtilsPhp5\Request;

// get the request instance
$request = Request::getInstance();

// get property
$ip = $request->getIp();
$method = $request->getMethod();

// get property of the array format
// ex: https://example.com?name=Lynk&job=developer
$queryString = $request->getQueryString(); // ['name' => 'Lynk', 'job' => 'developer']
// You can specify a key to get a value
$name = $request->getQueryString('name'); // Lynk

// You can even use dot notation to get nested values
// ex: request body: { user: { order: { id: 123 }}}
$orderId = $request->getBody('user.order.id'); // 123

Configure ipHeaderFilterChain

// You can configure the ipHeaderFilterChain by yourself. Headers earlier in the array are adopted first.
Request::setIpHeaderFilterChain([
  'HTTP_CLIENT_IP',
  'HTTP_X_FORWARDED_FOR',
  'REMOTE_ADDR'
]);

Response

  • Response::setHeader(string $name, string $value, bool $replace = true)
  • Response::setHeaders(array $headers, bool $replace = true)
  • Response::status(int $code)
  • Response::redierct(string $url, int $statusCode = 301)
  • Response::json(array $data, int $statusCode = 200)
  • Response::send(string $data, int $statusCode = 200)
<?php

require_once __DIR__ . '/../vendor/autoload.php';

use Link1515\HttpUtilsPhp5\Response;
use Link1515\HttpUtilsPhp5\Constant\Status;

Response::json(['message' => 'not found'], Status::NOT_FOUND);

Constant

This package also provides some common constant.

  • Link1515\HttpUtilsPhp5\Constant\Status
  • Link1515\HttpUtilsPhp5\Constant\Method
  • Link1515\HttpUtilsPhp5\Constant\ContentType

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

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

它主要适用于以下技术方向: 「http」 「response」 「request」 「php5」 「request headers」 「http methods」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-03-20