0

I have IIS 10 and my program calls curl_init function to make API calls. But I get this error: "Call to undefined function curl_init()" . Also when I look at the output of phpinfo() there is no cURL section showed up.

I've triple checked the php.ini file for extension=curl and ext folder for php_curl.dll. I also downloaded ssleay32.dll libeay32.dll files to system32 folder in C:. I restarted the server a couple of time. Still, when I check the phpinfo() there is no curl section there.

Here is what I have found in StackOverflow:

similar error

joshjdevl's answer may be the solution but what is the difference between thread-safe and non-thread-safe PHP package

Why does it work ?

about enabling curl extension here it is said that one should "add paths of your PHP directory to the Windows Environment PATH Variable for .dll dependencies." but in my local machine-my another machine-(with wampserver) I didn't add PHP to environment variables and it works, so do I really need to do that?

about making sure the system uses the correct php.ini file When I look at the phpinfo output I can see the path of the php.ini file. Based on that I assume IIS uses that php.ini file. I don't expect it to use another one.

about installing curl extension

I have searched more than 30 StackOverflow pages and still do not have a solution.

Mahmut Salman
  • 111
  • 1
  • 10

2 Answers2

0

After 8 hours of search and tens of StackOverflow questions, I've finally added the PHP path to environment variables and in the output of phpinfo() method cURL section started being shown and the error disappeared.

Windows Start -> Edit the system environment variables -> Advanced -> Environment Variables -> New..

For a more detailed explanation and for screenshots

But still have no idea why it works properly even though I didn't add PHP paths to Environment variables in my local machine. I assume it may be about wampserver configurations.

Mahmut Salman
  • 111
  • 1
  • 10
  • Sadly descriptions like "I've finally added the PHP path to environment variables" are less likely to help others as they are not accurate Windows terms and not specific enough. Besides, to better understand how PHP process locates libraries, you should use a tool like Process Monitor, which often reveals clearly which file paths are scanned. – Lex Li Aug 10 '22 at 06:15
  • BTW, PHP on Windows is going away as Microsoft discontinued its support for PHP 8 and above, https://news-web.php.net/php.internals/110907 So the earlier you might to Linux the better. – Lex Li Aug 10 '22 at 06:16
  • Thank you for your advice. I'll talk to my manager. And also I've edited my answer based on your comment. – Mahmut Salman Aug 10 '22 at 06:26
  • Its good to know that you have found the solution for your issue. You could accept your own answer whenever it is available to mark. It could help other community member with the similar issues. Thanks for your understanding. – Deepak-MSFT Aug 11 '22 at 07:57
0
  1. Open the php.ini file and go to the line that has this entry ;extension_dir = "ext". Remove this ; so that php will look for the php_curl.dll as well as other dlls in the ext folder.

  2. Go to the line that has this entry ;extension=php_curl.dll. Remove the ;

  3. Save.

  4. Then restart IIS.

  5. Check using the phpinfo().

This should load the curl and other modules.

benjie
  • 1
  • 2