juliangut/spiral 问题修复 & 功能扩展

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

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

juliangut/spiral

Composer 安装命令:

composer require juliangut/spiral

包简介

A PSR7 aware cURL client

README 文档

README

PHP version Latest Version License

Build Status Style Check Code Quality Code Coverage

Total Downloads Monthly Downloads

PSR7 aware cURL client

PSR7 compatible cURL client.

Use PSR7 Request and Response objects to perform HTTP Requests with cURL.

Installation

Best way to install is using Composer:

composer require juliangut/spiral

Then require_once the autoload file:

require_once './vendor/autoload.php';

Usage

use Jgut\Spiral\Client;

// Create Spiral cURL client
$spiralClient = new Client;

// Create \Psr\Http\Message\RequestInterface request and configure it
$request = new PSR7RequestImplementation();

// Perform the request providing an empty \Psr\Http\Message\ResponseInterface response object to be populated
$response = $spiralClient->request($request, new PSR7ResponseImplementation());

// Use response
$headers = $response->getHeaders();
$content = (string) $response->getBody();

Transport

You can create an empty cURL transport object and set options on it later

$transport = new Curl;

$spiralClient = new Client($transport);

Or you can create the transport object from sane defaults

$transport = Curl::createFromDefaults();

$spiralClient = new Client($transport);

If no transport object is provided to Jgut\Spiral\Client constructor method one will be created by Jgut\Spiral\Transport\Curl::createFromDefaults

Options

Transport object accepts cURL options

use Jgut\Spiral\Transport\Curl;
use Jgut\Spiral\Option\ConnectTimeout;

// Create Spiral cURL client
$transport = new Curl;

// Set option explicitly
$transport->setOption(new ConnectTimeout(10));

// Set by cURL constant
$transport->setOption(CURLOPT_CONNECTTIMEOUT, 10);

// Set using an alias
$transport->setOption('connect_timeout', 10);

Reserved options

Some options are reserved and cannot be added to transport object using setOption method. Some of them are set by extracting the relevant data from request oobject.

The following is a list of options automatically handled by the transport object

  • CURLOPT_NOBODY
  • CURLOPT_HTTPGET
  • CURLOPT_POST
  • CURLOPT_CUSTOMREQUEST
  • CURLOPT_URL
  • CURLOPT_POSTFIELDS
  • CURLOPT_HTTPHEADER

Available options

Option class Alias cURL constant Value type
AutoReferer auto_referer CURLOPT_AUTOREFERER bool
ConnectTimeout connect_timeout CURLOPT_CONNECTTIMEOUT int
Cookie cookie CURLOPT_COOKIE string
CookieFile cookie_file CURLOPT_COOKIEFILE string
CookieJar cookie_jar CURLOPT_COOKIEJAR string
Crlf crlf CURLOPT_CRLF bool
Encoding encoding CURLOPT_ENCODING string
FileTime file_time CURLOPT_FILETIME bool
FollowLocation follow_location CURLOPT_FOLLOWLOCATION bool
Header header CURLOPT_HEADER bool
HeaderOut header_out CURLINFO_HEADER_OUT bool
HttpAuth http_auth CURLOPT_HTTPAUTH bool
HttpVersion http_version CURLOPT_HTTP_VERSION float (1.0 or 1.1)
MaxRedirs max_redirs CURLOPT_MAXREDIRS int
Port port CURLOPT_PORT int
Referer referer CURLOPT_REFERER string
ReturnTransfer return_transfer CURLOPT_RETURNTRANSFER bool
SslVerifyPeer ssl_verify_peer CURLOPT_SSL_VERIFYPEER bool
SslVersion ssl_version CURLOPT_SSLVERSION int
Timeout timeout CURLOPT_TIMEOUT int
UnrestrictedAuth unrestricted_auth CURLOPT_UNRESTRICTED_AUTH bool
UserAgent user_agent CURLOPT_USERAGENT string
UserPwd user_password CURLOPT_USERPWD string (user:password)
Verbose verbose CURLOPT_VERBOSE bool

Review Jgut\Spiral\Option\OptionFactory for a full list of available aliases

Contributing

Found a bug or have a feature request? Please open a new issue. Have a look at existing issues before

See file CONTRIBUTING.md

License

Release under BSD-3-Clause License.

See file LICENSE included with the source code for a copy of the license terms

juliangut/spiral 适用场景与选型建议

juliangut/spiral 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 14.84k 次下载、GitHub Stars 达 3, 最近一次更新时间为 2015 年 10 月 28 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

围绕 juliangut/spiral 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

  • Stars: 3
  • Watchers: 2
  • Forks: 3
  • 开发语言: PHP

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2015-10-28