juststeveking/http-slim
Composer 安装命令:
composer require juststeveking/http-slim
包简介
A slim psr compliant http client to provide better interoperability.
关键字:
README 文档
README
The purpose of this package is to create an interoperable http client implementation allowing a "bring you own packages" approach to connection to 3rd party services.
The main goal of this package is to adhere to the following PSRs:
Installation
Using composer:
$ composer require juststeveking/http-slim
You are then free to use it as needed within your projects.
Next steps
The next step is to install a compliant package to do the request itself.
A few packages that are recommended:
Usage
Once you have installed a PSR-18 package and a PSR-17 package we do not need to do anything else. This package support HTTP Autodiscovery for your PSR compliant Client and Request factories. However, should you choose to inject you can do!
<?php declare(strict_types=1); use JustSteveKing\HttpSlim\HttpClient; use Symfony\Component\HttpClient\Psr18Client; // Injecting Clients: $httpClient = HttpClient::build( clientInterface: new Psr18Client(), requestFactory: new Psr18Client(), streamFactory: new Psr18Client(), ); // Using HTTP Auto-discovery $httpClient = HttpClient::build(); // perform a get request $httpClient->get( uri: 'https://api.example.com/v1/resource', ); // perform a post request $httpClient->post( uri: 'https://api.example.com/v1/resource', body: ['foo' => 'bar'], ); // perform a put request $httpClient->put( uri: 'https://api.example.com/v1/resource/identifier', body: ['foo' => 'bar'], ); // perform a patch request $httpClient->patch( uri: 'https://api.example.com/v1/resource/identifier', body: ['foo' => 'bar'], ); // perform a delete request $httpClient->delete( uri: 'https://api.example.com/v1/resource/identifier', ); // perform an options request $httpClient->options( uri: 'https://api.example.com/v1/resource/identifier', headers: ['X-OPTIONAL' => 'headers'], ); // Adding Plugins $httpClient->addPlugin( plugin: new \Http\Client\Common\Plugin\HeaderDefaultsPlugin( headers: ['Content-Type' => 'application/json'], ), );
Tests
There is a composer script available to run the tests:
$ composer run preflight:test
However, if you are unable to run this please use the following command:
$ ./vendor/bin/phpunit --testdox
Security
If you discover any security related issues, please email juststevemcd@gmail.com instead of using the issue tracker.
juststeveking/http-slim 适用场景与选型建议
juststeveking/http-slim 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 72.46k 次下载、GitHub Stars 达 7, 最近一次更新时间为 2020 年 05 月 29 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「psr-7」 「http-client」 「psr-17」 「psr-18」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 juststeveking/http-slim 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 juststeveking/http-slim 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 juststeveking/http-slim 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Model of a web-based resource
Simple PHP Library for RESTful APIs
Multipart PSR-7 stream factories based on PSR-17 factories.
Interfaces for web resource models and services to retrieve and create them
PSR-7 (HttpMessage) & PSR-17 (HttpFactory) Implementations
Interface for a factory to create Psr\Http\Message\StreamInterface objects
统计信息
- 总下载量: 72.46k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 7
- 点击次数: 24
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-05-29