Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/list/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Symfony 通过Guzzle的服务容器设置卷曲选项_Symfony_Curl_Guzzle - Fatal编程技术网

Symfony 通过Guzzle的服务容器设置卷曲选项

Symfony 通过Guzzle的服务容器设置卷曲选项,symfony,curl,guzzle,Symfony,Curl,Guzzle,我需要设置CURLOPT\u TCP\u NODELAYCURL选项,但问题是我不知道如何使用Sf2的服务容器来实现 下面是现在如何注射Guzzle: services: user.user_manager: class: Foo\UserBundle\Model\UserManager arguments: - @guzzle.client 但我还需要添加CURLOPT\u TCP\u节点延迟 普通PHP示例: $guzzle

我需要设置
CURLOPT\u TCP\u NODELAY
CURL选项,但问题是我不知道如何使用Sf2的服务容器来实现

下面是现在如何注射
Guzzle

services:
    user.user_manager:
        class: Foo\UserBundle\Model\UserManager
        arguments:
            - @guzzle.client
但我还需要添加
CURLOPT\u TCP\u节点延迟

普通PHP示例:

$guzzle = new \Guzzle\Http\Client(null, array(
    'curl.options' => array(
        'CURLOPT_TCP_NODELAY' => 1
)));

您可以创建自定义Guzzle客户端并将其声明为服务:

<?php

namespace You\ProjectBundle\Guzzle;

class MyGuzzleClient extends \Guzzle\Http\Client
{
    public function __construct()
    {
        parent::__construct(null, array(
            'curl.options' => array('CURLOPT_TCP_NODELAY' => 1)
        ));
    }
}
services:
    my_guzzle.client:
        class: You\ProjectBundle\Guzzle\MyGuzzleClient
最后,按如下方式使用:

services:
    user.user_manager:
        class: Foo\UserBundle\Model\UserManager
        arguments:
            - @my_guzzle.client

您可以创建自定义Guzzle客户端并将其声明为服务:

<?php

namespace You\ProjectBundle\Guzzle;

class MyGuzzleClient extends \Guzzle\Http\Client
{
    public function __construct()
    {
        parent::__construct(null, array(
            'curl.options' => array('CURLOPT_TCP_NODELAY' => 1)
        ));
    }
}
services:
    my_guzzle.client:
        class: You\ProjectBundle\Guzzle\MyGuzzleClient
最后,按如下方式使用:

services:
    user.user_manager:
        class: Foo\UserBundle\Model\UserManager
        arguments:
            - @my_guzzle.client

谢谢我想可能还有别的办法。可能是用这些表达?谢谢!我想可能还有别的办法。可能是用这些表达?