承接 fast-forward/http-client 相关项目开发

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

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

fast-forward/http-client

最新稳定版本:v1.1.0

Composer 安装命令:

composer require fast-forward/http-client

包简介

Fast Forward PSR-18 HTTP Client Factory

README 文档

README

PHP Version Composer Package Tests Coverage Docs License GitHub Sponsors

PSR-11 PSR-18

FastForward HTTP Client is a focused integration package that registers a PSR-18 HTTP client in a FastForward-compatible container. It uses Symfony HttpClient as the transport layer and exposes Psr\Http\Client\ClientInterface for application code.

What this package does

  • Registers Psr\Http\Client\ClientInterface as Symfony\Component\HttpClient\Psr18Client
  • Registers Symfony\Component\HttpClient\HttpClient through HttpClient::create()
  • Fits naturally into fast-forward/container service-provider based configuration

Important note for first-time users

This package does not register PSR-17 factories on its own. To resolve Psr\Http\Client\ClientInterface, your container must already provide:

  • Psr\Http\Message\ResponseFactoryInterface
  • Psr\Http\Message\StreamFactoryInterface

In a FastForward application, the usual solution is to install fast-forward/http-factory or the all-in-one fast-forward/http metapackage.

Installation

Install the package itself:

composer require fast-forward/http-client

Choose one of these setups:

  • If your container already provides PSR-17 factories, fast-forward/http-client is enough.
  • If you want explicit FastForward PSR-17 and PSR-18 providers, install fast-forward/http-client fast-forward/http-factory.
  • If you want the shortest onboarding path, install fast-forward/http.

Quick start

This example uses both fast-forward/http-factory and fast-forward/http-client so it works in a fresh project:

<?php

declare(strict_types=1);

use FastForward\Http\Client\ServiceProvider\HttpClientServiceProvider;
use FastForward\Http\Message\Factory\ServiceProvider\HttpMessageFactoryServiceProvider;
use Psr\Http\Client\ClientInterface;
use Psr\Http\Message\RequestFactoryInterface;

use function FastForward\Container\container;

$container = container(
    new HttpMessageFactoryServiceProvider(),
    new HttpClientServiceProvider(),
);

/** @var RequestFactoryInterface $requestFactory */
$requestFactory = $container->get(RequestFactoryInterface::class);
$request = $requestFactory->createRequest('GET', 'https://example.com');

/** @var ClientInterface $client */
$client = $container->get(ClientInterface::class);
$response = $client->sendRequest($request);

$statusCode = $response->getStatusCode();
$body = (string) $response->getBody();

Registered services

Service ID Resolved object Typical use
Psr\Http\Client\ClientInterface Symfony\Component\HttpClient\Psr18Client Portable PSR-18 application code
Symfony\Component\HttpClient\HttpClient A runtime-selected Symfony\Contracts\HttpClient\HttpClientInterface implementation Native Symfony HttpClient features

Documentation

The Sphinx documentation in docs/ now covers:

  • installation paths for beginners
  • the dependency on PSR-17 factories
  • direct Symfony client usage versus PSR-18 usage
  • override patterns for timeouts, headers, and base URIs
  • compatibility notes and FAQ entries for common setup mistakes

License

This package is open-source software licensed under the MIT License.

Contributing

Contributions, issues, and pull requests are welcome at php-fast-forward/http-client.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-06-12

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固