我刚刚看到有一个新版本的pecl_http扩展可用,请参见the documentation。它带来了一个新的接口,与旧的扩展没有任何相似之处,所以我想问一下,有没有关于如何使扩展工作的例子?我安装了它,也安装了对raphf和propro的要求。但即使是一个简单的
$client = new http\Client();给了我一个致命的错误
Uncaught exception 'http\Exception\UnexpectedValueException' with message 'Failed to locate "(null)" client request handler' in情况也是如此。
$client = new http\Client('curl');只是和Failed to locate "curl"在一起。
我希望看到一个http\Client实例化的工作示例和一个对网站的简单GET请求。
发布于 2014-05-30 22:52:18
我在debian上遇到了这个问题。
有帮助的是安装curl的nss版本:
apt-get install libcurl4-nss-dev然后重新安装pecl_http,并在它询问libcurl时提供以下路径
/usr/lib/x86_64-linux-gnu/libcurl.so发布于 2014-07-05 10:21:51
这里有一个很酷的要点,叫做Using version 2 of PECL HTTP extension (pecl_http)。这篇文章不是我写的,但它展示了一些如何使用版本2的好例子。
发布于 2014-01-13 22:05:23
请参阅文档:http://devel-m6w6.rhcloud.com/mdref/http/
示例:
<?php
$client = new http\Client;
$client->enqueue(new http\Client\Request("HEAD", "http://php.net"));
$client->enqueue(new http\Client\Request("HEAD", "http://pecl.php.net"));
$client->enqueue(new http\Client\Request("HEAD", "http://pear.php.net"));
printf("Transfers ongoing");
while ($client->once()) {
// do something else here while the network transfers are busy
printf(".");
// and then call http\Client::wait() to wait for new input
$client->wait();
}
printf("\n");
while ($res = $client->getResponse()) {
printf("%s returned %d\n", $res->getTransferInfo("effective_url"),
$res->getResponseCode());
}
?>http://devel-m6w6.rhcloud.com/mdref/http/Client/once
https://stackoverflow.com/questions/20939095
复制相似问题