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
谢谢我想可能还有别的办法。可能是用这些表达?谢谢!我想可能还有别的办法。可能是用这些表达?