prestashop/module-lib-guzzle-adapter
Composer 安装命令:
composer require prestashop/module-lib-guzzle-adapter
包简介
Plug modules to the Guzzle client available on a running shop
README 文档
README
Plug modules to the Guzzle client available on a running shop. This library is compatible with PHP 7.2.5 and above.
Installation
composer require prestashop/module-lib-guzzle-adapter
Version Guidance
| Version | Status | Packagist - | Namespace | Repo | Docs | PHP Version |
|---|---|---|---|---|---|---|
| <=0.5 | Stable | prestashop/module-lib-guzzle-adapter |
Prestashop\ModuleLibGuzzleAdapter |
v0.x | N/A | >=7.2.5 |
| >=0.6 | Latest | prestashop/module-lib-guzzle-adapter |
Prestashop\ModuleLibGuzzleAdapter |
v0.x | N/A | >=5.6.0 |
| 1.x | Latest | prestashop/module-lib-guzzle-adapter |
Prestashop\ModuleLibGuzzleAdapter |
v1.x | N/A | >=7.2.5 |
Usage
# Getting a client (Psr\Http\Client\ClientInterface) $options = ['base_url' => 'http://some-url/']; $client = (new Prestashop\ModuleLibGuzzleAdapter\ClientFactory())->getClient($options); # Sending requests and receive response (Psr\Http\Message\ResponseInterface) $response = $this->client->sendRequest( new GuzzleHttp\Psr7\Request('POST', 'some-uri') );
In this example, base_url is known to be a option for Guzzle 5 that has been replaced for base_uri on Guzzle 6+. Any of this two keys can be set, as it will be automatically modified for the other client if needed.
The automatically changed properties are:
| Guzzle 5 property | Guzzle 7 property | |
|---|---|---|
| base_url | <=> | base_url |
| defaults.authorization | <=> | authorization |
| defaults.exceptions | <=> | http_errors |
| defaults.timeout | <=> | timeout |
Why this library?
Making HTTP requests in a PrestaShop module can be done in several ways. With file_get_contents(), cURL or Guzzle when provided by the core.
Depending on the running version of PrestaShop, the bundled version of Guzzle can be different:
- PrestaShop 1.7: Guzzle 5
- PrestaShop 8: Guzzle 7
Having a module compatible for these two major PrestaShop versions can be tricky. The classes provided by the two Guzzle version are named the same, but their methods are different.
It is not possible for a module contributor to require its own Guzzle dependency either, because PHP cannot load different versions of a same class and he would never know which one would be loaded first.
Implementation notes
This library reuses the idea behind PHP-HTTP, where the implementation of HTTP requests should be the same (PSR) whatever the client chosen.
The client files from php-http/guzzle5-adapter and php-http/guzzle7-adapter have been copied in this repository because these libraries both require a different version Guzzle in their dependencies to work. Requiring them together would conflict, so we duplicated the client adapters to be safe.
prestashop/module-lib-guzzle-adapter 适用场景与选型建议
prestashop/module-lib-guzzle-adapter 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 78.78k 次下载、GitHub Stars 达 3, 最近一次更新时间为 2022 年 06 月 10 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 prestashop/module-lib-guzzle-adapter 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 prestashop/module-lib-guzzle-adapter 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 78.78k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 18
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: AFL-3.0
- 更新时间: 2022-06-10