PHPackages                             steady-as-hill/sooh-curl - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [HTTP &amp; Networking](/categories/http)
4. /
5. steady-as-hill/sooh-curl

ActiveLibrary[HTTP &amp; Networking](/categories/http)

steady-as-hill/sooh-curl
========================

curl

1.0(7y ago)013MITPHP

Since Jun 28Pushed 7y ago1 watchersCompare

[ Source](https://github.com/waynewn/sooh-curl)[ Packagist](https://packagist.org/packages/steady-as-hill/sooh-curl)[ RSS](/packages/steady-as-hill-sooh-curl/feed)WikiDiscussions master Synced yesterday

READMEChangelog (1)DependenciesVersions (2)Used By (0)

curl 封装
=======

[](#curl-封装)

ServiceProxy项目（基于http协议的微服务中间件）需要扩展curl,原版本扩展性较差，因此有了这次的重构

基本用法
----

[](#基本用法)

先看两个例子

```
    $ret = \Sooh\Curl::getInstance()->httpGet('http://www.baidu.com');
    echo "httpCode:".$ret->httpCode."\n";
    echo "content:".$ret->body."\n";
    echo "new cookies set:".json_encode($ret->newCookies)."\n";

```

稍微复杂些的

```
    //前期初始化
    $curl = \Sooh\Curl::getInstance(array('SESSIONID'=>'afasdf'),new \Sooh\CurlClasses\Headers(array('some-header: value','other-header'=>'value')));

    //第一次请求，标准post
    $curl->disposables('Cookies',array('CookieTest'=>1))->httpPost('http://1.2.3.4/adsf',array('a'=>1));
    //此次服务器收到的请求，cookie 有两个SESSIONID=afasdf 和 CookieTest=1

    后面第二次请求，rawdata方式提交了个json数据
    $curl->disposables('Cookies',array('CookieAgain'=>2))->httpRawJson('http://1.2.3.4/adsf',array('a'=>1));
    //此次服务器收到的请求，cookie 有两个SESSIONID=afasdf 和 CookieAgain=2

```

### 初始化 及 设置

[](#初始化-及-设置)

static function getInstance() 肩负初始化和获取实例的双重责任

初始化时会登记一些addons，比如cookie,此时记录的数据，在释放前全程有效

后面处理业务的时候，可以通过-&gt;disposables(addons名称，参数)， 调用指定addone的disposables方法，记录一些一次性的数据，在接下来的请求中用掉

说明：初始化的时候，getInstance()可以接收不定数量的参数， 除了cookie(可以给数组，内部转成Addons),其他都必须是Addons的实例

### 三种请求格式

[](#三种请求格式)

public function httpGet($url,$params=null,$timeOut = 5)

public function httpPost($url,$params,$timeOut=5)

public function httpRawJson($url, $params,$timeOut=5)

函数名可以说明问题了，这里只说明一下，params 根据具体的函数情况，string 或 array 都支持

返回结果，下面的结构应该不用多解释了

```
    class Ret {
        public $httpCode;
        public $newCookies=array();
        public $body;
        public $error;
        ……

```

### addons

[](#addons)

目前提供了四个Addons

1. Header的
2. proxy代理设置的
3. 标准Cookie的
4. ServiceProxy项目使用的CookiesForServiceProxy(基于标准Cookie)，通过cookie记录很多辅助信息：uid,路由策略,请求链初始时间等

初始化需要很多额外参数(其中，key参数，允许有两个，逗号分割，验签的时候，两个key都会试，但生成签名用的是第一个)，

同时提供下面两个方法：

- public function getTimestampStart() 获取整个请求链最初的时间
- public function getRequestSN() 获取初始化时得到（或生成）的请求的唯一SN

curl 提供了 getAddons() 获取指定的Addons

### 其他

[](#其他)

关于资源释放：

curl-&gt;freeAddons(false) 释放掉所有addons的disposables数据

curl-&gt;freeAddons(true) 连同addons一起，全部释放掉

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

2876d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/c8f4ca102171f00a75538266b967af5dcf17882e2cc351312ae734d7db3d3888?d=identicon)[waynewn](/maintainers/waynewn)

---

Top Contributors

[![waynewn](https://avatars.githubusercontent.com/u/9529021?v=4)](https://github.com/waynewn "waynewn (2 commits)")

---

Tags

curl

### Embed Badge

![Health badge](/badges/steady-as-hill-sooh-curl/health.svg)

```
[![Health](https://phpackages.com/badges/steady-as-hill-sooh-curl/health.svg)](https://phpackages.com/packages/steady-as-hill-sooh-curl)
```

###  Alternatives

[rmccue/requests

A HTTP library written in PHP, for human beings.

3.6k34.5M258](/packages/rmccue-requests)[kriswallsmith/buzz

Lightweight HTTP client

2.0k31.3M443](/packages/kriswallsmith-buzz)[nategood/httpful

A Readable, Chainable, REST friendly, PHP HTTP Client

1.8k17.2M267](/packages/nategood-httpful)[mashape/unirest-php

Unirest PHP

1.3k9.7M161](/packages/mashape-unirest-php)[php-http/curl-client

PSR-18 and HTTPlug Async client with cURL

48247.0M384](/packages/php-http-curl-client)[smi2/phpclickhouse

PHP ClickHouse Client

83510.1M71](/packages/smi2-phpclickhouse)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
