How to manually install Curl in a one-off PHP script - php

WIN 10 Microsoft PC (not linux). I've installed PHP V 7.1.9.
Right now, i'm trying to install Curl. However I'm getting odd issues,
phpinfo :-
1) Curl is reporting an AUTHOR of Sterling Hughes, however no modules are active / found for curl.
So i'm guessing it knows the author - php knows curl is available ?
2) the file path for the Configuration File (php.ini) shows the path C:\WINDOWS, however Ive checked there & there is NO php.ini file located.
I have checked for hidden files too...
Ive got PHP installed in 2-3 other directories (i guess in one of the PATH directories, so thats why php is loading.)
QUERIES:
3) is there a php code to diagnose the true / correct pathname of where the php.ini is loaded from ? So i can edit it & uncomment the line about installing the curl dll file.
(I have those lines uncommented in the php.ini files I could find).
4) Is there a way in a php script to "load" up Curl if its not in the php.ini file ?
(ive downloaded CURL in a ZIP file & extracted the files).
all the examples so far refer to php.ini, but no examples of PHP code to activate / load up Curl from within a php script itself without being installed via the php.ini file.

Retrieve PHP.ini path: You can try with PHP functions. php_info() or php_ini_loaded_file()
http://php.net/manual/en/function.phpinfo.php
http://php.net/manual/en/function.php-ini-loaded-file.php
Way to load up CURL dynamically ?
You can't. There was a function to achieve it but had been removed.
http://php.net/dl
To install Curl, follow the instruction below
http://php.net/manual/en/curl.installation.php
Similar question(Very helpful):
PHP and CURL under Windows 7 64 bits and Apache

Related

PHP SOAP extension not working (PHP + IIS + SOAP Extension)

I'm having some issues trying to achieve a SOAP request to a web service by using PHP.
I have a really small project which only send some requests of a SOAP web service, parses them and show the results on a table, but it's not working. I've developed this using XAMPP and this is the very first time I deploy something on a IIS web server so I'm a newbie.
I'm not using any framework, it's just plain PHP.
The first problem I have is that php_soap.dll extension seems to be disabled since I check the configuration with php_info(); and I can't find SOAP extension in the result, but I've enabled it in my php.ini by removing the semicolon from that line and my extension folder is "ext" under my PHP folder. I have some other extensions running and they're just fine.
Doing some var_dump when I try to instatiate the SOAP class, it's not returning anything (not even null).
Some more info:
PHP Version: 7.3.25
IIS Version: 10.0.17763.1 running on Windows Server 2019
2022-09-05 Edit
I've found out that php_openssl.dll isn't working on my server. I don't know why. It's enbled in php.ini. However, phpinfo(); shows it as disabled.
On the other hand, when I run "php -m" command on my CMD, it shows that SOAP and OpenSSL are enabled:
The first thing you need to do is enable the php_soap extension in your php.ini file. You can do this by removing the semicolon from the line that says ;extension=php_soap.dll. Once you have done this, restart your web server.
Next, you need to make sure that the extension_dir setting in your php.ini file points to the directory where your PHP extensions are located. For example, if your extensions are in the c:\php\ext directory, then your extension_dir setting should look like this:
extension_dir = "c:\php\ext"
Once you have done this, restart your web server.
If you still cannot get the SOAP extension to work, please post a comment below and I will try to help you further.
I already solved my problem.
The problem was not in the PHP.ini file, that one was correctly configured.
The problem was that I hadn't installed an extension for PHP and IIS. Once I've installed PHP Manager For IIS and configured it by following this tutorial, it worked out correctly.

Calling undefined curl_init() function in IIS

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.
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.

PHP scws extention is not loaded by MAMP

I have a problem about loading extension of PHP in MAMP:
I have compiled and installed scws.so (PHP extension for Chinese words segmentation) into folder '/Applications/MAMP/bin/php/php5.3.6/lib/php/extensions' together with other extensions like pgsql.so, etc.
Also, I've updated the php.ini under '/Applications/MAMP/bin/php/php5.3.6' by adding 'extension=scws.so'.
If I issue command '/Applications/MAMP/bin/php/php5.3.6/bin/php -m' in console, I can see 'scws' is in the output list. But it has not been loaded after starting MAMP, also, I can not see 'scws' is listed with function phpinfo().
Could anyone help me about how to force the load of the new PHP extension? Why it is listed by 'php -m', but actually not loaded by MAMP?
Thanks in advance!
The configuration for PHP called from web server is different from command line php. In phpinfo() check the path to the php.ini file that is being used and make sure that it is the same file that you edited to add the extensions.

GD2 library in PHP not installing

I'm having problems installing the GD library. I'm using an IIS server with PHP 5.2.14. I uncommented extension=php_gd2.dll in php.ini.
This is the error:
gd: Unable to initialize module
Module compiled with module API =20060613
PHP compiled with modlule API = 20090626
These options need to match
in Unknown on Line 0
I downloaded various PHP versions to try and get the correct DLL, including thread-safe 5.2.14. I would then restart my application pool and try to load a file that uses the GD library. Are there other files necessary for gd2 to work? Are there any quick ways to solve this without reinstalling PHP entirely?
first, iis7 was not configured properly for php - I searched for a guide that walked me through. Second the directory was incorrect, whenever I reset the iis server it originally would say one directory when ISAPI api was being used- but after 2 mins it would say extension_dir was in another directory when cgi/fastcgi is being used. So i created that directory that it wanted (which was different than any of my php.ini's). The one it was pulling from needed to be put in the C:/windows directory, but even though I had it set to go to "./ext" it wanted to go to Program files/PHP-- extremely weird. Third, I had to add IUSR to the permissions of any folder being used.

installing php_printer on wamp server

Ive been googling around on how to install the php_printer.dll for wamp server, nothing came up. Perhaps, anyone know how to install that ext? Basically, im trying to use php printer function and i need that extension as i heard. i tried http://www.issociate.de/board/goto/751941/Call_to_undefined_function_printer_open().html to install on wamp server, but still give me error in the webpage? i added the extension: php_printer.dll in php.ini
testing code:
<?php
$filename = "test page";
///////
ob_start();
include $filename;
$contents = ob_get_contents();
ob_end_clean();
///////
$handle = printer_open("HP80AA62");
printer_set_option($handle, PRINTER_MODE, "raw");
printer_write($handle,$contents);
printer_close($handle);
?>
Although I don't have much experience with installing/enabling extensions myself, this has worked for me in the past:
Ensure that php_printer.dll is listed under the "ext" directory inside of your PHP installation. If it isn't there, you will need to download that extension and save it under the "ext" directory.
Add the extension inside of php.ini.
Reboot your server and try again.
Hope that helps,
spryno724
Not
extension: php_printer.dll
You should use
extension=php_printer.dll
Also, be noticed that there are plenty of versions of php_printer.dll and most of them don't work on Windows platform.
Try to get fresh one: pecl-5.2.6-Win32.zip.
Also, consider this line form PHP: Printer manual
Windows users must enable
php_printer.dll inside of php.ini in
order to use these functions. A DLL
for this PECL extension is currently
unavailable.
I've just tried to enable it on Wamp (Windows XP) and it doesn't work.
After enabling the php_printer.dll in your ini, I'd first make sure you did it in the good INI file (by looking at "Loaded Configuration File" in phpinfo()).
Then if proper INI is loaded, but the module still isn't working, I'd go to command prompt and try running php manually, like php -v
That will probably give you an error with some more data on the issue - that error wouldn't be visible anywhere through your browser, that is - when you run a page in browser.
In the end - the error that you'll get reported will most probably be that you are trying to load the module which is compiled as 'thread safe' while your version of PHP was compiled as non-thread safe. Or it will be the other way around.
To overcome that, you'll need to download the proper version of PECL. I think that the link mentioned earlier by Wh1T3h4Ck5 is the thread-safe one.
You can try this link:http://museum.php.net/php5/pecl-5.2.6-nts-Win32.zip or maybe here, it's a bunch of win32 binaries:
http://snaps.php.net/win32/
After you download that, take the printer dll from it, copy to your c:\php\ext (or whatever you use), reset the web server and it should work. If it does well, then the php -v shouldn't give errors any more. You can also use the php -m at that point, to list all the modules loaded, or just check the phpinfo() again.
That was the scenario I had and that's how I solved it.
see the path for "Loaded Configuration File" in your php info page. then add extension=php_printer.dll on that php.ini file. mine, it was "D:\wamp\bin\apache\apache2.4.4\bin\php.ini" at "Loaded Configuration File" on php info page.
after you added, it may give a warning like, php startup: unable to load dynamic library 'path/to/php_printer.dll' - the specified module cannot be found on wamp
I got solved this by changing versions of Apache, PHP and MySQL too. correct versions are:
PHP 5.2.6
MySQL 5.0.45
Apache 2.2.9
Hope this helps.
If you can use xampp 1.6.8 version it will fix these issues. it has php 5.2.6 and also php_printer.dll file has saved in ext folder in php folder. so you will only have to un-comment the line extension=php_printer.dll in php.ini file which noticed in the path under "Loaded Configuration File" section on php info page. you can find that version of xampp from www.oldapps.com

Categories