A simple php_curl example isn't working anymore on my Windows 10 laptop. It was working before.
Fatal error: Uncaught Error: Call to undefined function curl_init() in C:\Users\path\curl.php:3 Stack trace: #0 {main} thrown in C:\Users\path\curl.php on line 3
My C:\php7\php.ini has extension=C:\php7\ext\php_curl.dll
php_curl.dll exists in C:\php7\ext
PHP Version 7.0.30
Windows 10 Pro Version 1607 Build 14393.2189
But my loclahost/phpinfo.php does not have cURL. How come all of a sudden it disappeared ?
PS : The script worked in the command line. It's just that Apache is not loading the extension.
don't know why it suddenly stopped working, but first run <?php phpinfo(~0); , and check which php.ini file that is actually loaded (this avoids editing the wrong php.ini file to no avail) (in this example, it is /etc/php/7.0/fpm/php.ini), then edit that php.ini file, if that file actually has the extension=C:\php7\ext\php_curl.dll line, then some combination of the following settings are set wrong:
display_startup_errors is Off, change it to On
display_errors is Off, change it to On
error_reporting is not E_ALL, change it to error_reporting=E_ALL (and nothing else, not like error_reporting= E_ALL & ~E_NOTICE or whatever, just E_ALL)
html_errors is Off, change it to On
then restart apache, again check the phpinfo() page, and verify that the new configuration options are actually loaded, then run <?php curl_init();, and it should show an error about why the curl extension could not be loaded.
I came across some links on other StackOverflow answers (will post the links here if I trace them again). I had Apache 2.4.23 Win64 - I reinstalled Apache to the latest one - 2.4.33 Win64 - and now cURL is working.
Related
I have a simple test code:
<?php
var_dump(curl_init());
echo '.';
if I run it on command line (Windows 10) I get the expected result:
php.exe test.php
resource(4) of type (curl) .
very fine. But when Im running this file from browser (set to Apache rootdir).
Fatal error: Uncaught Error: Call to undefined function curl_init() in
Im speachless. For legacy reasons, this is php 7.04 (on 7.2, 7.4, 8.1 everything is fine).
The php.ini does work. Of course "extension=php_curl.dll" is enabled. When I change something, for example "max_execution_time = 300", the php_info(); also reinforcements me that these settings are taken into account.
However, the strange thing is what php_info() is saying:
cURL Sterling Hughes
nothing more for curl!
EDIT:
I tried the same with "extension=php_gd2.dll" and it does work if I remove/readd it, phpinfo shows that correctly!
This is because the php folder is not in your system PATH (not user), Apache doesn't know where to search dlls. The easiest way is adding php folder to PATH.
If you doesn't want to do that, you probably need set extension_dir to the full path of your extension folder in php.ini. for example:
extension_dir = "D:\Program Files\php-7.04-ts\ext"
cURL extension needs openssl to work. and you can also find these dlls in php folder, just copy them to Windows or system32 folder. According to RiggsFolly's comment you can copy these required dlls to Apache\bin folder.
libssl-1_1-x64.dll / libeay32.dll
libcrypto-1_1-x64.dll / ssleay32.dll
libssh2.dll
I'm getting the error when trying to access any page running on the builtin php webserver (including just a phpinfo):
Fatal error: Could not delete queued timer in Unknown on line 0
This is the command I am using to run the server
~/php-win$ wine php.exe -S localhost:8080
Here is the content of my php.ini file, which I am assuming is the cause of the error because of the Unknown on line 0 part.
Through trial and error I have discovered that if I comment out the max_input_time value then pages will load fine however the error shows up at the bottom of the page instead. See the below image:
I also had the exact same issue when attempting to set up an EasyPHP server as well (through wine also).
The only other question I could find on this error was this question, however this is happening when I run any file through the built-in webserver, including a blank file.
Also, I am using PHP 7.1.3
Edit your php.ini and put the location of extension folder , the folder named ext inside your php folder
php.ini
; Directory in which the loadable extensions (modules) reside.
; http://php.net/extension-dir
; extension_dir = "./"
; On windows:
extension_dir = "/media/viney/01D58852BCA3B9C0/UwAmp/bin/php/php-7.0.3/ext"
Then I enable a few extensions in php.ini
php.ini
extension=php_soap.dll
extension=php_sockets.dll
extension=php_sqlite3.dll
extension=php_tidy.dll
extension=php_xmlrpc.dll
extension=php_xsl.dll
Now if I run php, extenions get loaded
viney#Notebook:/media/viney/01D58852BCA3B9C0/UwAmp/bin/php/php-7.0.3$ wine php -S localhost:8080
PHP 7.0.3 Development Server started at Mon May 4 09:28:07 2020
Listening on http://localhost:8080
Document root is Z:\media\viney\01D58852BCA3B9C0\UwAmp\bin\php\php-7.0.3
Press Ctrl-C to quit.
I'm programming in php on my machine where I freshly installed:
Centos 6: centos-release-6-10.el6.centos.12.3.x86_64
Php 7 - PHP 7.0.31 (cli) (built: Jul 17 2018 15:40:48) ( NTS ) (Zen Engine 3.0.0)
Apache 2 - Server version: Apache/2.2.15 (Unix)
As fresh install nothing were logged. (first time this happens)
My php info tell me I have /etc/php.ini configuration file, where I have:
error_reporting = E_ALL
display_errors = Off
display_startup_errors = On
log_errors = On
log_errors_max_len = 0
html_errors = On
error_log = /var/log/httpd/php-error.log
On php info I see correct variables as wrote here.
In httpd.conf
ErrorLog "/var/log/httpd/error_log"
LogLevel debug
There is no ovewrite configuration in my virtualhost. I just tried debug to fix this issue, but nothing.
To make sure for me that anything can have access to log path, I used chmod 777 on the folders /var, /var/log, /var/log/httpd, and on error.log apache file. I didn't on php error file since it's not present, and as far as I know, Apache (or php) sould create it on it's own.
My php has eveident errors, and on different environment (with php 5) is naturally logged on apache log file.
I obviously restarted apache service at any change.
I searched really a lot before asking, and nothing that was suggested has never worked.
Am I really missing something?
Thanks. Riccardo
Update: After the best badge I could have earned: "Tumbleweed", I want to update with something more I tried:
I tried with code inside the php file:
ini_set("log_errors", 1);
ini_set("error_log", "/tmp/php-error.log");
error_log( "Hello, errors!" );
And nothing was logged.
display_errors = on in php.ini
This didn't work either
I'm really struggling programming without a error log...
Thanks to anyone.
Finally I got what was the problem.
Well.. maybe it is just MY problem...
By the way, with php 7.0 I had a php.ini corrupted file, I didn't see it had a lot of strange character.
I had to correct all the file and everything worked as a charme.
Hope anyone else could benefice from this.
For some reason my php extensions stopped working (they were working fine before).
curl for example:
curl_init();
returns an undefined function error.
In php.ini extension=php_curl.dll and extension_dir = "c:/wamp/bin/php/php5.5.12/ext/" are both set and correct.
extension_loaded('curl') returns false
Cant find anything useful in apache/php error log files. Tried resetting apache.
Im running Windows 8 64bit.
Any suggestions?
Try uncommenting this line PHPIniDir c:/wamp/bin/php/php5.5.12
I'm having trouble getting php -l(the built in linter) to actually recognize that the file it's linting has issues. I'm on Mac OS X Lion, running php 5.3.8. I verified through the command line (php -i) that display_errors is set to On and error_reporting is set to E_ALL | E_STRICT.
Here is my test file, I've tried others with the same result:
<?php
abcde
for {
?>
running that through php -l nets the response:
No syntax errors detected in test.php
Are you sure you edited correct php.ini? Confirm it with phpinfo()