定制 phprise/http-client 二次开发

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

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

phprise/http-client

最新稳定版本:v1.0.0

Composer 安装命令:

composer create-project phprise/http-client

包简介

Atomic repository for Client of HTTP Connector based on The OTAKU Manifesto.

README 文档

README

The Atomic Repository is the smallest possible unit of granularity. It enforces a strict architectural boundary through the following rules:

  1. No Subdirectories: Only one level of directory inside src/.
  2. Maximum 10 Files: Only 10 files per package.
  3. Strict Typing: Mandatory declare(strict_types=1) and full type hinting for all properties and methods.
  4. Object Calisthenics: Maximum of 50 lines per class and 2 instance variables to ensure extreme cohesion.
  5. Value Objects: All primitives must be wrapped. Raw strings or integers are not permitted in domain logic.
  6. First Class Collections: Arrays are forbidden for data transport; use dedicated Collection objects.
  7. Tell, Don't Ask: Getters and setters are prohibited. Objects must expose behavior, not state.
  8. Infrastructure Ignorance: The domain core is decoupled from persistence, frameworks, and external tools.
  9. Logic Flow: The else keyword is banned. Use guard clauses and early returns to minimize indentation.

Installation

Install the package via composer:

composer require phprise/http-client

Usage

This repository contains the HTTP Client implementation. It is an Atom of the HTTP system, providing the fundamental mechanism to transmit requests and receive responses.

NativeClient

The NativeClient is a lightweight, CURL-based implementation of Psr\Http\Client\ClientInterface and Http\Client\HttpAsyncClient.

Synchronous Usage

use Phprise\Http\Client\NativeClient;

$client = new NativeClient();
$response = $client->sendRequest($request);

echo $response->getStatusCode();

Asynchronous Usage

The client supports asynchronous requests via the Httplug Promise interface.

use Phprise\Http\Client\NativeClient;

$client = new NativeClient();
$promise = $client->sendAsyncRequest($request);

$promise->then(
    fn($response) => echo "Success: " . $response->getStatusCode(),
    fn($exception) => echo "Error: " . $exception->getMessage()
);

Important

The NativeClient is designed to be a "silent" tool. It doesn't contain business logic or high-level orchestration; its only job is to fulfill the contract of sending a request through the data pipe.

Philosophy

We follow The OTAKU Manifesto: Fluid Structure Design.

  1. O - Own your Discipline (Be strict with yourself)
  2. T - Tools for Composition (Compose like Unix)
  3. A - Armor the Core (Protect the heart of the business)
  4. K - Keep Infrastructure Silent (Infrastructure is just a detail)
  5. U - Universal Language & Contracts (Speak the user's language via clear contracts)

Please read more about it in PHILOSOPHY.md.

License

MIT License

Free to use, modify, and distribute.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-01-22

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固