php-http/discovery 问题修复 & 功能扩展

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

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

php-http/discovery

Composer 安装命令:

composer require php-http/discovery

包简介

Finds and installs PSR-7, PSR-17, PSR-18 and HTTPlug implementations

README 文档

README

Latest Version Software License Tests Code Coverage Quality Score Total Downloads

This library provides auto-discovery and auto-installation of well-known PSR-17, PSR-18 and HTTPlug implementations.

Install

Via Composer

composer require php-http/discovery

Usage as a library author

Please see the official documentation.

If your library/SDK needs a PSR-18 client, here is a quick example.

First, you need to install a PSR-18 client and a PSR-17 factory implementations. This should be done only for dev dependencies as you don't want to force a specific implementation on your users:

composer require --dev symfony/http-client
composer require --dev nyholm/psr7

Then, you can disable the Composer plugin embeded in php-http/discovery because you just installed the dev dependencies you need for testing:

composer config allow-plugins.php-http/discovery false

Finally, you need to require php-http/discovery and the generic implementations that your library is going to need:

composer require 'php-http/discovery:^1.17'
composer require 'psr/http-client-implementation:*'
composer require 'psr/http-factory-implementation:*'

Now, you're ready to make an HTTP request:

use Http\Discovery\Psr18Client;

$client = new Psr18Client();

$request = $client->createRequest('GET', 'https://example.com');
$response = $client->sendRequest($request);

Internally, this code will use whatever PSR-7, PSR-17 and PSR-18 implementations that your users have installed.

Usage as a library user

If you use a library/SDK that requires php-http/discovery, you can configure the auto-discovery mechanism to use a specific implementation when many are available in your project.

For example, if you have both nyholm/psr7 and guzzlehttp/guzzle in your project, you can tell php-http/discovery to use guzzlehttp/guzzle instead of nyholm/psr7 by running the following command:

composer config extra.discovery.psr/http-factory-implementation GuzzleHttp\\Psr7\\HttpFactory

This will update your composer.json file to add the following configuration:

{
    "extra": {
        "discovery": {
            "psr/http-factory-implementation": "GuzzleHttp\\Psr7\\HttpFactory"
        }
    }
}

Don't forget to run composer install to apply the changes, and ensure that the composer plugin is enabled:

composer config allow-plugins.php-http/discovery true
composer install

Testing

composer test

Contributing

Please see our contributing guide.

Security

If you discover any security related issues, please contact us at security@php-http.org.

License

The MIT License (MIT). Please see License File for more information.

php-http/discovery 适用场景与选型建议

php-http/discovery 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 336.83M 次下载、GitHub Stars 达 1.32k, 最近一次更新时间为 2015 年 06 月 02 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 336.83M
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1329
  • 点击次数: 34
  • 依赖项目数: 1392
  • 推荐数: 35

GitHub 信息

  • Stars: 1322
  • Watchers: 12
  • Forks: 47
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-06-02