1

I'm starting with this error:

Call to undefined function curl_init()

Fine, so I go to PHP's php.ini file and uncomment:

;extension=curl to extension=curl

I restart Apache, and?

Call to undefined function curl_init()

I added the full PHP directory to the system paths, and?

Call to undefined function curl_init()

So I check phpinfo() and I see the module is loaded for cURL but no other string instances mentioned:

PHP's get_loaded_extensions() does not list cURL.

So I figure, I might as well install a fresh version of cURL.

So the main cURL page doesn't have binaries for Windows of course. So I eventually find my way to https://curl.se/download.html#Win64. Now I've gone through their documentation and they don't have anything about installing the binaries but they have information about building them. Which is like having a guy give you a spare inflated tire but not the tools to install it but he wants to tell you where to get the spare next time, not helpful.

So I've got a ZIP file with cURL and the readme file has no installation instructions. None of the documentation from what I can see clarifies what to do with the files.

  1. Do I simply drag-and-drop the files to the php\ext folder? It contains a libcurl-x64.dll file, I guess I can either rename it to simply libcurl.dll or add a custom extension entry in php.ini but I'm not sure and I can't find documentation specific to that.
  2. Do I have to add a custom entry for my php.ini file?

How do I install (the binary version of) cURL for PHP on Windows?

  • Running PHP 8.3 on Windows 10 x64.
  • php.ini path is set: extension_dir = "C:\PHP\ext\".
  • PHP cURL's author's name appears in phpinfo() however not the cURL header like on my live LAMP server.
  • Running php.exe from the command line does not return error messages.

Edit 1

I checked the Apache error log and found this:

PHP Warning: PHP Startup: Unable to load dynamic library 'curl' (tried: C:\PHP\ext\curl (The specified module could not be found), C:\PHP\ext\php_curl.dll (The specified module could not be found)) in Unknown on line 0

I have the extension absolutely defined (extension=C:\PHP\ext\php_curl.dll) and still got this error.

Edit 2

I came across a tutorial to run the following from the command line:

deplister.exe ext\php_curl.dll

It produced the following list:

  • php8ts.dll,OK
  • libcrypto-3-x64.dll,OK
  • libssl-3-x64.dll,OK
  • CRYPT32.dll,OK
  • WLDAP32.dll,OK
  • Normaliz.dll,OK
  • libssh2.dll,OK
  • nghttp2.dll,OK
  • KERNEL32.dll,OK
  • ADVAPI32.dll,OK
  • WS2_32.dll,OK
  • bcrypt.dll,OK
  • VCRUNTIME140.dll,OK
  • api-ms-win-crt-heap-l1-1-0.dll,NOTFOUND
  • api-ms-win-crt-stdio-l1-1-0.dll,NOTFOUND
  • api-ms-win-crt-string-l1-1-0.dll,NOTFOUND
  • api-ms-win-crt-runtime-l1-1-0.dll,NOTFOUND
  • api-ms-win-crt-convert-l1-1-0.dll,NOTFOUND
  • api-ms-win-crt-filesystem-l1-1-0.dll,NOTFOUND
  • api-ms-win-crt-utility-l1-1-0.dll,NOTFOUND
  • api-ms-win-crt-time-l1-1-0.dll,NOTFOUND
  • api-ms-win-crt-math-l1-1-0.dll,NOTFOUND

So clearly some version of Visual C++ is missing. I'll post another follow-up soon.

1
  • php -i | find ".ini" Commented Sep 22 at 17:15

3 Answers 3

-1

You need to ensure the ext directory is set correctly In your php.ini, check this line: extension_dir = "ext" It should point to the ext folder inside your PHP installation (where php_curl.dll is located). Example: extension_dir = "C:\xampp\php\ext" then restart your web server

  • If you’re using XAMPP, restart Apache from the XAMPP control panel.
  • If you’re using IIS or another setup, restart that service. Verify installation Run:

php -m | findstr curl

Or create a phpinfo() page in your web root:

<?php phpinfo(); ?> 

Then open it in your browser and check for curl.

2
  • I have it set: extension_dir = "C:\PHP\ext\". I'm running a baseline WAMP server, not XAMPP. Commented Sep 22 at 12:03
  • Any idea which Visual C++ redistributable I need? I updated my post. Commented Sep 22 at 12:23
-1

Problem: Unable to load dynamic library 'curl' / 'php_curl.dll' could not be found

Likely Cause: Wrong extension_dir value, missing DLL, wrong build (architecture), or dependent DLLs missing Solution: Check path, copy the correct DLL, ensure all required dependent DLLs are present, match architecture / thread safety.

-1

Someone elsewhere on the web said that dumping the libssh2.dll file in to Apache\bin directory fixed the problem. I found more documentation and these basic instructions fixed cURL to work on Windows:

Edit the C:/Apache/conf/httpd.conf file:

  • LoadFile "C:/Apache/bin/libeay32.dll"
  • LoadFile "C:/Apache/bin/libssh2.dll"
  • LoadFile "C:/Apache/bin/ssleay32.dll"

Restart Apache and cURL will work correctly. I think this has something to do with OpenSSL offhand but 99.9% of everything PHP+cURL related is simply removing the semi-colon and restarting Apache. I think people forget that, hello, it's going to make Internet requests with the https:// protocol and it needs a way to do so securely.

1
  • It’s not someone elsewhere but the official PHP page, php.net/manual/en/curl.installation.php which should be your first stop to locate the right guidance. Commented Sep 22 at 16:15

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.