Class 'SoapClient' not found on Google Cloud PHP App - php

I deployed my php app to Google Cloud and getting currently the following error when i call the line.
$url = "S5WS.wsdl";
$client = new \SoapClient(dirname(__FILE__) . DIRECTORY_SEPARATOR . $url, array('trace' => true, 'soap_version' => SOAP_1_1));
PHP message:
PHP Fatal error: Class 'SoapClient' not found in /app/controllers/TicketController.php on line 211
I opened the terminal in the Google Cloud and typed php -i | grep -i soapso to check the status of the soap and it seemds to be fine.
baltacii#s5-app-****:/$ php -i | grep -i soap
soap
Soap Client => enabled
Soap Server => enabled
soap.wsdl_cache => 1 => 1
soap.wsdl_cache_dir => /tmp => /tmp
soap.wsdl_cache_enabled => 1 => 1
soap.wsdl_cache_limit => 5 => 5
soap.wsdl_cache_ttl => 86400 => 86400
baltacii#s5-app-167912:/$
If i call phpinfo(); in the app.It returns me in contrast to my localhost no Soap Section. There are only 2 lines related with the soap.
SOAP Brad Lafountain, Shane Caraveo, Dmitry Stogov
and in the configure command section
'--enable-soap=shared'
EDIT: App runs on PHP Version 5.6

So according to documentation some PHP extensions are compiled as shared, but disabled by default.Soap is one of these extensions.In order to activate it. We should create a php.ini in the base folder of the project.
php.ini
; Enable the Soap extension
extension=soap.so
After new deployment to server soap should be available.

Related

Installing php-soap on nginx with multiple php versions

I am running a few sites that has different php versions running (7.0 and 7.4)
For one of the sites, when I try to run soap code, I get:
Uncaught Error: Class 'SoapClient' not found
When I run
php -i | grep -i soap
i get the following output:
/etc/php/7.4/cli/conf.d/20-soap.ini,
soap
Soap Client => enabled
Soap Server => enabled
soap.wsdl_cache => 1 => 1
soap.wsdl_cache_dir => /tmp => /tmp
soap.wsdl_cache_enabled => 1 => 1
soap.wsdl_cache_limit => 5 => 5
soap.wsdl_cache_ttl => 86400 => 86400
I need to install the soap for php 7.0 and I am not that familiar with linux so I would love to get some step by step instructions.
Thanks!

No oci8 module in phpinfo()

I try to set up connection with oracle database, but I still can't even set up the module. I have rhel 7. 2 server, and I followed whole tutorial for setting up oracle instantclient and configured it with php. One thing I completely don't understand is that oci8 module displays after php -i execution:
oci8
OCI8 Support => enabled
OCI8 DTrace Support => disabled
OCI8 Version => 2.1.3
Revision => $Id: 59f993160cf983dd24bb391b68a65a17303d2dba $
Oracle Run-time Client Library Version => 12.1.0.2.0
Oracle Compile-time Instant Client Version => 12.1
Directive => Local Value => Master Value
oci8.connection_class => no value => no value
oci8.default_prefetch => 100 => 100
oci8.events => Off => Off
oci8.max_persistent => -1 => -1
oci8.old_oci_close_semantics => Off => Off
oci8.persistent_timeout => -1 => -1
oci8.ping_interval => 60 => 60
oci8.privileged_connect => Off => Off
oci8.statement_cache_size => 20 => 20
But there is no such module in phpinfo() inside the script. How to fix it?
PHP Version 7.0.13
Server Apache (httpd)
LD library path:
[![enter image description here][2]][2]
The common problem would be that LD_LIBRARY_PATH isn't set for Apache.
Try adding it to /etc/sysconfig/httpd like:
LD_LIBRARY_PATH=/full/path/to/oracle-client
If I have my versions right, this version of Apache (i) doesn't like the export keyword for setting variables (ii) requires a full path since it won't expand environment variables. If I'm wrong, try either or both of those.
There is a lot of information about setting the environment in the free Underground Oracle & PHP Manual, see, for example 'Setting Oracle Environment Variables for Apache' on p 108
You say you followed 'whole tutorial'. There are many tutorials. I'd recommend Oracle's installation instructions.
The answer is:
setsebool -P allow_execstack 1
You also can enable executable stack for only oci8.so with:
execstack -c /usr/lib64/php/modules/oci8.so
https://serverfault.com/questions/314336/centos-6-php-can-not-load-gdchart-so-and-oci8-so-compiled-by-me
make sure that the oci8.so is in the php extension folder
in centos is /usr/lib64/php/modules
in ubuntu xammp is /opt/lampp/lib/php/extensions/no-debug-non-zts-20170718
cd <extension folder >
sudo chmod 755 oci8.so
It works for me after
ps ax | grep "fpm"
check the pid of "php-fpm: master process"
sudo kill -9 <pid>
start php-fpm again
sudo service php-fpm start
inspired by https://stackoverflow.com/a/21693610/2538630

Warning: SoapClient::SoapClient(http://www.w3.org/2005/05/xmlmime): failed to open stream: HTTP request failed! HTTP/1.1 401 Authorization Required

I have simple script connection call using PHP 5.2.10 to a Web service working with SOAP 1.2.
The same PHP installation is able to connect via Web service to another web server working with SOAP 1.1 without issues. In addition, the web services using 1.2 is working fine with another two servers using almost the same hard code.
However, every time I am using SOAP 1.2 on this server with PHP 5.2.10 I got the bellow error if I run the script from a batch file:
Warning: SoapClient::SoapClient(http://www.w3.org/2005/05/xmlmime): failed to open stream: HTTP request failed! HTTP/1.1 401 Authorization Required in C: \NewSimpleConnectionTest.php on line 10
If the script is running via Eclipse PHP with PHP 5.2 on a different computer, it does not have any error so the hard code seems fine, user and password are correct too because it is used on the others servers and on the Eclipse test:
My script is this:
<?php
$_endpoint = "http://server:8080/serverv/ServerAPI";
$_username = "userServer";
$_password = "123ABC!";
try
{
$client = new SoapClient($_endpoint."?WSDL", array('location' => $_endpoint, 'login' => $_username, 'password' => $_password, 'trace' => 1, 'features' => SOAP_USE_XSI_ARRAY_TYPE + SOAP_SINGLE_ELEMENT_ARRAYS, 'soap_version' => SOAP_1_2));
echo 'Connected to Web Services.';
}catch(Exception $e){
echo 'Failure to connect to WebServices.';
}
?>
This is the information in the SOAP and XML phpinfo.
SimpleXML
Simplexml support => enabled
Revision => $Revision: 1.151.2.22.2.46 $
Schema support => enabled
soap
Soap Client => enabled
Soap Server => enabled
Directive => Local Value => Master Value
soap.wsdl_cache => 1 => 1
soap.wsdl_cache_dir => /tmp => /tmp
soap.wsdl_cache_enabled => 1 => 1
soap.wsdl_cache_limit => 5 => 5
soap.wsdl_cache_ttl => 86400 => 86400
Any idea about what is missing or the problem on this PHP version to work with SOAP 1.2 in that server?
Thanks in advance!!
After some hours working around this problem, the solution was changing the version of PHP from 5.2.10 to 5.5.28.
There is some kind of bug on this old version and prevent the correct connection with SOAP 1.2.
I hope this help someone using this old version of PHP.

oci_connect() only works on cli

Ive installed httpd and httpd-devel packages and installed php and php-devel on a server. I downloaded and installed the basic client and sdk for oracle and then proceeded to use PECL to install OCI8 extension.
When I try running the oci_connect function page on CLI, It works fine. But when I try to load the same php page over http, i get the following error:
Fatal error: Call to undefined function oci_connect() in /var/www/html/index.php on line 10
I have compared the php ini from both and notice that /etc/php.d/oci8.ini file is loaded in the cli and the http version
however, the module details are only available on the cli version:
oci8
OCI8 Support => enabled
OCI8 DTrace Support => disabled
OCI8 Version => 2.0.8
Revision => $Id: f04114d4d67cffea4cdc2ed3b7f0229c2caa5016 $
Oracle Run-time Client Library Version => 12.1.0.2.0
Oracle Compile-time Instant Client Version => 12.1
Directive => Local Value => Master Value
oci8.connection_class => no value => no value
oci8.default_prefetch => 100 => 100
oci8.events => Off => Off
oci8.max_persistent => -1 => -1
oci8.old_oci_close_semantics => Off => Off
oci8.persistent_timeout => -1 => -1
oci8.ping_interval => 60 => 60
oci8.privileged_connect => Off => Off
oci8.statement_cache_size => 20 => 20
I cant for the life of me figure out why only one loads the extension properly when they both have the same configuration file.
Thanks for any help!
I managed to fix this by disabling SELINUX

php cannot load pecl http extension

I have installed pecl_http on a PLESK server (which seems to be successful) but for some reason, the http extension will not load into PHP.
var_dump(extension_loaded("http"));
gives me bool(false).
pecl info pecl_http gives me a lot of info and if I run php -me http is also listed.
php -i | grep "http_request" gives me:
http_request => N/A => 0 => 0
http_request_datashare => GLOBAL => 1 => 0
http_request_pool => N/A => 0 => 0
and if I run pecl run-tests -p pecl_http I get a lot of FAILs
and I am also getting
Fatal error: Call to undefined function http_get()
http.so is located inside /usr/lib/php/modules/ which is also defined as the extension dir in php.ini - all other extensions loads fine.
What have I missed?
What happens if change
enable_dl = Off
to
enable_dl = On
in php.ini and run
php -r "dl('http.so');"
?

Categories