glooby/http-client-bundle

高级 http 代理

安装: 329

依赖: 0

建议: 0

安全: 0

星星: 2

关注者: 2

分支: 0

类型:symfony-bundle

0.1.1 2017-03-29 21:01 UTC

This package is auto-updated.

Last update: 2024-09-20 07:55:00 UTC


README

需求

  • PHP 5.6 或更高版本
  • [Guzzle PHP 框架][guzzle] (由 composer 包含)
  • Symfony 2.7 或更高版本(包括 Symfony 3.x)

安装

要安装此扩展包,运行以下命令,您将通过 [Packagist][packagist] 获取最新版本。

composer require glooby/http-client-bundle dev-master

要使用最新版(可能是不稳定的)版本,请将以下内容添加到您的 composer.json 中

{
    "require": {
        "glooby/http-client-bundle": "dev-master"
    }
}

在 AppKernel.php 中加载扩展包

    public function registerBundles()
    {
        $bundles = [
            ...
            new Glooby\HttpClientBundle\GloobyHttpClientBundle(),
            ...
        ];
    }

配置

在 app/config/parameters.yml 中进行配置

parameters:
...
    glooby.http.proxy: socks5://127.0.0.1:1080

文件

parameters:
...
    glooby.http.proxy: /etc/proxyfile
$ cat /etc/proxy

socks5://127.0.0.1:1080

支持单行或多行

parameters:
...
    glooby.http.proxy:
        - http://127.0.0.1:1081
        - socks5://127.0.0.1:1080
        - socks4://127.0.0.1:1082

混合

parameters:
...
    glooby.http.proxy:
        - socks5://127.0.0.1:1080
        - socks5://john:doe@127.0.0.1:1081
        - /etc/proxy1
        - /etc/proxy2

当提供多个代理时,每次创建新客户端时将随机选择一个

用法

$ip = $this->get('glooby.http.client')->get('http://api.ipify.org')->getBody();

支持

支持的代理类型

  • http
  • https
  • socks4
  • socks4a
  • socks5
  • socks5h

许可证

此扩展包在 MIT 许可证 下发布