PHP PECL_HTTP 与 cURL 扩展

发布于 2024-08-18 05:30:19 字数 441 浏览 4 评论 0原文

我正在为 CouchDB 开发 PHP 客户端。在浏览有关 HTTP 和 cURL 的 php.net 文档时,我遇到了 PECL_HTTP 扩展。乍一看,我想我想使用这个 PECL 扩展而不是 cURL,因为它使用起来更简单,而且我也没有做非常复杂的 HTTP 工作。另外,我总是喜欢尝试新事物,所以我不介意把脚弄湿。

至于我向 StackOverflow 社区提出的问题:

  • 有人同时使用过 PECL_HTTP 和 cURL 扩展吗?
  • PECL 扩展是否存在严重的性能问题?
  • PECL 扩展是否像表面上看起来那样用户友好?
  • 久经考验的 cURL 库仍然优越吗?

编辑:事实证明,PECL_HTTP 扩展在幕后使用了一些 cURL 源代码,因此它们并不是完全不同的野兽。两者都是 PHP 的编译扩展。

I'm working on a PHP Client for CouchDB. While browsing through the php.net documentation regarding HTTP and cURL, I came across the PECL_HTTP Extension. At first glance, I think I would like to use this PECL extension instead of cURL because it's much simpler to use, and I'm not doing very complicated HTTP work anyways. Plus I always like trying new things, so I wouldn't mind getting my feet wet.

As far as my question to the StackOverflow community:

  • Has anyone used both the PECL_HTTP and cURL extensions?
  • Does the PECL extension have any serious performance issues?
  • Is the PECL extension as user-friendly as it appears on the surface?
  • Is the tried-and-true cURL library still superior?

Edit: As it turns out, the PECL_HTTP extension uses some of the cURL source code under the hood, so they aren't completely different beasts. Both are also compiled extensions to PHP.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

红颜悴 2024-08-25 05:30:19

在我看来,CURL 非常简单且易于掌握。在 PHP Cookbook(O'Reilly,2002)中,出于各种(性能)原因选择了 CURL。

In my opinion CURL is straightforward and easy to pick up. In PHP Cookbook (O'Reilly, 2002) CURL was chosen for various (performance) reasons.

爱人如己 2024-08-25 05:30:19

事实证明,PECL_HTTP 扩展使用起来要简单得多,在某些地方几乎将我的代码减半。 :)

The PECL_HTTP extension has proven much simpler to use, almost cutting my code in half in some places. :)

愚人国度 2024-08-25 05:30:19

首先我不得不说我们在我们公司都使用过,从处理上来说我更喜欢 php_http 并且我很欣赏 Mike 的工作。

但我们放弃了 php_http,因为它没有捆绑在普通 php 中。我们在Windows环境中工作,对于每个没有被php本身捆绑的pecl扩展,我们必须自己编译它(这不是一件坏事)。编译时我们收到一个错误,指出缺少一些标头。事实证明这完全是我们的错,因为文档中已经明确说明了这一点。

从 php_http 2.0 版本开始,它有两个非标准依赖项:
- raphf 1.0.0 或更新版本
- propro 1.0.0 或更新版本

因此我们需要编译的不仅仅是 php_http。
但对于 propro 1.0.0 (2013-08-12) config.w32 在下载中丢失(至少在编写状态下)。
所以我们必须自己写一个。等等...

最终我们让它在 PHP 5.5 VC11 x86 上工作,但是花了一些时间。在公司里你有时没有时间花在这些事情上。
Curl 总是开箱即用,因为它是捆绑的。这可能是不使用 php_http 的一个严重原因。

我真的很感激的是,如果 php_http 能把它变成普通的 php 。

希望这对一些决策者有帮助;-)

At first I have to say we used both at our company and from the handling I like php_http more and I appreciate the work of Mike.

But we abandoned php_http because it is not bundled in vanilla php. We are working in a windows environment and for each pecl extension which is not bundled by php itself, we have to compile it ourselves (which is not a bad thing). While compiling we got an error that some headers were missing. It turned out it was totally our fault, because it's clearly stated in the documentation.

And the since version 2.0 of php_http, it has two none-standard dependancies:
- raphf 1.0.0 or newer
- propro 1.0.0 or newer

So we needed to compile more than only php_http.
But for propro 1.0.0 (2013-08-12) config.w32 was missing in the download (at least in the state of writing).
So we had to write our own one. And so on...

In the end we got it working for PHP 5.5 VC11 x86, but it took some time. In companies you sometimes doesn't have time to spend on such things.
Curl always works out of the box, because it's bundled. This might be a serious reason not to use php_http.

Something I would really appreciate is if php_http would do it into vanilla php.

Hope this helps some decision makers ;-)

橘亓 2024-08-25 05:30:19

我还没有尝试过PECL_HTTP。我更喜欢使用 cURL,因为我可以先在命令行中测试它。此外,cURL 在标准 Linux 安装中可用,因此我可以期望它在各种基于 Linux 的托管中可用。我不知道 PECL 的可用性,因为我没有在我的代码中使用它的任何函数。

I haven't try PECL_HTTP yet. I prefer to use cURL, since I can test it out in command line first. Also, cURL is available in standard linux installation, so I can expect it to available in various linux-based hosting. I don't know about PECL availability, because I don't use any of it's function in my code.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文