Enable curl in PHP 8.1 with WAMP

English 简体中文 繁体中文 ภาษาไทย Tiếng Việt
Summary

Enabling cURL in PHP 8.1 with WAMP often encounters issues where `curl_init()` fails despite the extension being enabled in `php.ini`. To resolve this, developers should first confirm `extension=php_curl.dll` (or `extension=curl` for PHP 8) and `extension_dir` are correctly configured. A critical step involves downloading a PHP 8.2 or later version to obtain specific DLLs. Copy `libcrypto-3-x64.dll`, `libssh2.dll`, and `nghttp2.dll` from the newer PHP version's `bin` folder into the Apache `bin` directory. Finally, restart all WAMP services to activate cURL, which can then be verified via `phpinfo()`.

之前,我们已经完成了在WAMP中安装PHP 8(从PHP 5升级到PHP 8)。 一切运行良好,但最近我们注意到,在将代码从PHP 5迁移到PHP 8的过程中,curl_init()无法正常工作。经过检查,我们发现curl扩展没有正确加载,即使该扩展已在php.ini中启用。

在这篇文章中,我们将展示如何在WAMP中启用PHP 8的curl。 我们使用的PHP版本是PHP 8.1.31。

要在PHP 8中启用curl,我们需要修改php.ini文件,尝试在php.ini中搜索curl,您应该确认curl扩展已启用。

extension=php_curl.dll

或者,如果您使用的是PHP 8,请确认

extension=curl

另请检查extension_dir是否已正确设置。

此后,请下载PHP 8.2或更高版本,因为PHP 8.1存在一些兼容性问题(仅用于复制一些dll),请将以下dll复制到apache bin文件夹。

  • libcrypto-3-x64.dll
  • libssh2.dll
  • nghttp2.dll

PHP 8.2及更高版本的bin文件夹

Apache bin文件夹

然后重新启动所有服务,如果您检查 phpinfo()输出,您应该会看到curl已启用

WAMP SOLUTION CURL UNDEFINED TROUBLESHOOTING PHP 8 CURL_INIT

  RELATED

  COMMENTS

0

No comment for this article.