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 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 link1515/http-utils-php5 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
repository php library
HTTP request logger middleware for Laravel
Class to generate a standard structure for api json responses
Adds request-parameter validation to the SLIM 3.x PHP framework
http客户端
Easily add Excepct-CT header to your project
统计信息
- 总下载量: 21
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 15
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-03-20