How can I check whether the server is able to handle SOAP requests at run time ? I need to verify it before my script is executing.
8 Answers
From SSH you can run:
php -i | grep Soap
that will return something like:
Soap Client => enabled
Soap Server => enabled

- 401
- 4
- 8

- 352
- 3
- 11
In PHP to check whether SOAP enabled or not use built in function class_exists()
:
var_dump(class_exists("SOAPClient"));
It also could be user to check any of modules classes.

- 16,332
- 16
- 58
- 82
-
1Why was this answer down-voted? It's a lot more direct and usable than the `phpinfo` "solutions", and perhaps even more direct than `extension_loaded`. – meustrus Jul 10 '14 at 21:00
-
1Because the OP wants to check SOAP at run time before its script is executing. See the question. – Epoc Sep 12 '14 at 19:47
in the command line type the following:
>> php -r 'echo (extension_loaded("soap")?"LOADED\n":"not loaded\n");'

- 34,531
- 8
- 55
- 100

- 2,452
- 25
- 19
in a php file :
<?php
echo phpinfo();
?>
and then look for SOAP and you will see if SOAP is installed and enabled
EDIT : be careful with other solutions using php CLI (Command Line Interface), because you don't have the same php.ini used for the CLI and for your web server (for example apache). Thus it may differ.
Then if you use apache and you want to see if soap is enabled, it's better to indicate the apache php.ini file in the command line, for instance :
php -c /etc/php/apache2/php.ini -i | grep Soap

- 3,430
- 4
- 20
- 27
Hmm... I'm new and I'm bad : I tried this in a "test.php" file.
<?php
if (extension_loaded('soap'))
{
echo phpinfo();
}
else //will redirect to sth else so you know it doesn't work
{
header("Location: http://localhost/index.html");
die();
}
?>
And I saw myself looking at a "phpinfo()" page with a paragraph called : "soap".
Sorry for the misinterpretation.
To install SOAP :
Check your "php.ini" file, look for "extension".
You should find a line :
extension=php_soap.dll
or ;extension=php_soap.dll
";" means it's commented.
Uncomment it.
If you didn't find the line, then put it there.
extension=php_soap.dll
Make sure the dll file actually is in the default folder php/ext
.
If it isn't, check on phpinfo() is your version is VC6, VC9 of VC11, go to the php download page : http://windows.php.net/download#php-5.6 and get the correspondant version of php zip file.
Steal their "php_soap.dll" from their /ext folder and put it in yours.
You're all set!
Restart your servers, then go to your phpinfo() test page to check if it works.
Good luck.
Note :
phpinfo() simple test.php file :
<php
echo phpinfo();
?>

- 51
- 2
PEAR packages are not listed in phpinfo(), so if "soap" doesn't appear on your "test.php" page, it's normal !

- 51
- 2
-
1a code example would be nice to help the questioner understand your answer better :) – zpontikas Apr 17 '15 at 07:50
You can use the phpinfo script to see is SOAP is installed.
http://[your-domain.com]/phpinfo.php

- 170,088
- 45
- 397
- 571

- 17
- 1