如何在 PHP 5.x 上安装 http_pecl?

How to install http_pecl on PHP 5.x?

我正在尝试在 Ubuntu 14.04 上安装 pecl_http,但它报告需要 PHP 7。

$ sudo pecl install pecl_http
pecl/pecl_http requires PHP (version >= 7.0.0), installed version is 5.5.9-1ubuntu4.14
pecl/raphf requires PHP (version >= 7.0.0), installed version is 5.5.9-1ubuntu4.14
pecl/propro requires PHP (version >= 7.0.0), installed version is 5.5.9-1ubuntu4.14
No valid packages found
install failed
$

在 Debian 上类似:

pecl/pecl_http requires PHP (version >= 7.0.0), installed version is 5.6.17-0+deb8u1
pecl/raphf requires PHP (version >= 7.0.0), installed version is 5.6.17-0+deb8u1
pecl/propro requires PHP (version >= 7.0.0), installed version is 5.6.17-0+deb8u1

我找不到 changelog 任何信息表明 pecl_http 不向后兼容 PHP 5.x。

我尝试使用 PHP 7.0 并安装成功,但是我可以做些什么来使用 PHP 5.x 安装它?

您需要找出哪个版本的 pecl_http 不需要当前版本的 PHP,然后专门安装那个版本。根据文档:

"Package[-version/state][.tar]" : queries your default channel's server (pear.php.net) and downloads the newest package with the preferred quality/state (stable).

To retrieve Package version 1.1, use "Package-1.1," to retrieve Package state beta, use "Package-beta." To retrieve an uncompressed file, append .tar (make sure there is no file by the same name first)

according to the changelogpecl_http 3.0是第一个PHP 7兼容版本,所以也许试试以前的。

最终答案:您会寻找 sudo pecl install pecl_http-2.5.5

这个问题有一个公认的答案,但我会在主题上加上我的 2 美分:

基于您的 PHP 版本:

  • 对于PHP 7 使用'pecl install oci8'
  • 对于 PHP 5.2 至 5.6 使用 'pecl install oci8-2.0.12'
  • 对于 PHP 4.3.9 至 5.1 使用 'pecl install oci8-1.4.10'

OCI8 2.0.12PHP 5.6.x[=12= 的最终版本]

OCI8 2.1.x只对PHP有效 7

正在为 PHP 5.6.31 安装 OCI8:

[root@server bin]# ./pecl install oci8-2.0.12
WARNING: channel "pecl.php.net" has updated its protocols, use "pecl channel-update pecl.php.net" to update
downloading oci8-2.0.12.tar ...
Starting to download oci8-2.0.12.tar (1,615,360 bytes)
....
11 source files, building
running: phpize
Configuring for:
...

PHP 5.6.31 and OCI8 2.0.12

的预期输出

这是安装 OCI8 支持的最简单方法。