PHP Error Class 'SoapClient' not foundPosted in Apache and PHP -
I've often found that something gets left out or forgotten when moving a website from an old server to a new install. I've just finished migrating one of my customer's sites to a new CentOS 5.0 install with Apache 2.2 and PHP 5.1.6, and there's one single PHP script in the site which uses the SoapClient class.
Naturally I'd forgotten to test this particular function until after the migration was complete, and was wondering why the script had failed. A quick look in the Apache error log file revealed the following error message:
[Wed Sep 25 00:50:12 2007] [error] [client 10.1.1.2] PHP Fatal error: Class 'SoapClient' not found in /path/to/filename.php on line 469
Aha! I'd forgotten to install the SOAP extension when I'd installed PHP on this particular CentOS machine. Not being to sure what the package would be called, I did this:
yum search soap | grep php
which returned the following:
php-soap.x86_64 5.1.6-5.el5 base php-soap The php-soap package contains a dynamic shared object that will add php-soap.x86_64 5.1.6-11.el5 updates php-soap The php-soap package contains a dynamic shared object that will add php-soap.x86_64 5.1.6-7.el5 updates php-soap The php-soap package contains a dynamic shared object that will add php-soap.x86_64 5.1.6-12.el5 updates php-soap The php-soap package contains a dynamic shared object that will add php-soap.x86_64 5.1.6-15.el5 updates php-soap The php-soap package contains a dynamic shared object that will add php-soap.x86_64 5.1.6-15.el5 updates php-soap The php-soap package contains a dynamic shared object that will add
So that tells me I need to install the "php-soap" package; pretty straight forward name which I should have been able to guess...
$ yum install php-soap ============================================================================= Package Arch Version Repository Size ============================================================================= Installing: php-soap x86_64 5.1.6-15.el5 updates 135 k Updating for dependencies: php x86_64 5.1.6-15.el5 updates 1.2 M php-cli x86_64 5.1.6-15.el5 updates 2.3 M php-common x86_64 5.1.6-15.el5 updates 139 k php-devel x86_64 5.1.6-15.el5 updates 511 k php-gd x86_64 5.1.6-15.el5 updates 112 k php-imap x86_64 5.1.6-15.el5 updates 52 k php-mbstring x86_64 5.1.6-15.el5 updates 975 k php-mysql x86_64 5.1.6-15.el5 updates 86 k php-pdo x86_64 5.1.6-15.el5 updates 62 k php-xml x86_64 5.1.6-15.el5 updates 98 k Transaction Summary ============================================================================= Install 1 Package(s) Update 10 Package(s) Remove 0 Package(s) Total download size: 5.6 MB Is this ok [y/N]:
As you can see, there were also some updates to some of the PHP packages I had already installed, so these were installed at the same time. After the install was complete, it was just a matter of restarting Apache and the SoapClient class could now be used by my PHP script.
Using YUM to install software can be done on CentOS, Red Hat Enterprise Linux, Fedora and some other Linux distributions. Others may use different package managers and call the packages different names, so the method of installing PHP SOAP will be different from Linux distribution to Linux distribution.