I have a fresh Ubuntu 12.04 installation with a basic web server setup including pecl and OAuth; However, when I run a simple index file (as shown below) I am getting a fatal error:
PHP Fatal error: Class 'OAuth' not found in /var/www/index.php on line 2
Here is my file:
<?php
$oAuth = new \OAuth(CONSUMER_KEY, PRIVATE_KEY);
Obviously the consumer/private keys are my actual keys.
Now I have checked phpinfo() and OAuth is definitely in there. I have it set in my php.ini. I have restarted Apache.
When I run pecl list
Installed packages, channel pecl.php.net
Package Version State
oauth 1.2.3
stable pecl_http 1.7.6 stable
extension_loaded('oauth') // returns true
there's no oAuth in php -m either
Any ideas why I am still getting class not found? I hope it's not something dumb I am missing :)
Cheers guys.
Related
I need to call an API using PECL from my Server. I installed PEAR and PECL from the PHP PEAR Packages in Cpanel. .I attached the screenshot. But when I run my code $request = new HttpRequest(); it returns an error Fatal error: Class 'HttpRequest' not found in /home/wonr/public_html/sms_api.php on line 3
It is shared hosting.Is this causing because of the path error? Or do I need to do any additional setup on the Server?
I cannot find additional information on this.
Thank you.
I follow the solution of PHP Fatal error: Class 'OAuth', but still get the same error.
installation
$ sudo pecl install oauth
then add the following line to the end of /etc/php/7.0/cli/php.ini
extension=/usr/lib/php/20151012/oauth.so
Both "php -m" and "php --re oauth" return something. But "php -z" does not work and no OAuth from phpinfo() either.
$ php -z oauth /var/www/html/oauth.php
Failed loading oauth: oauth: cannot open shared object file: No such file or directory
PHP Notice: Undefined index: HTTP_HOST in /var/www/html/oauth.php
One thing to note, I am running PHP on apache2 as docker container behind nginx proxy. Would that be a problem? I verify PHP via phpinfo(), which is working fine.
The system is Ubuntu 16.04, also.
$ pecl list
Installed packages, channel pecl.php.net:
=========================================
Package Version State
oauth 2.0.2 stable
Thanks for the help.
The $_SERVER['HTTP_HOST'] only exists when run php as web server or cgi mode. So if you run in cli mode, the $_SERVER does not contain HTTP_HOST index. Try to access a not exiting index will throw a notice.
Otherwise, if a request is over ip rather than host, this index would not exist.
I am trying to configure MongoDB on the AWS server, but when I try to make an API call, I get the following error:
Fatal error: Class 'MongoDB\Driver\Manager' not found in /srv/www/api/releases/20160912135146/vendor/mongodb/mongodb/src/Client.php on line 56
I have done the following:
Install mongodb, following the instructions here -> install mongodb community edition on ubuntu
installed the php mongodb driver using pecl install mongodb
added extension=mongodb.so to php.ini at etc/php5/cli/php.ini
Started the mongodb service
on the server, I can enter the mongo console with $ mongo
What am I missing here, Please?
PS: the API is developed using Phalcon
I finally found a solution to this. Apparently, the apache server uses a special php.ini file, different from etc/php5/cli/php.ini. This file is located in etc/php5/apache2/php.ini. After installing the mongodb driver using pecl install mongodb, your extension should go in etc/php5/apache2/php.ini i.e add extension = mongodb at the end of etc/php5/apache2/php.ini. Good luck
There are tons of questions on this topic, but none of them have worked for me. I originally had the mongodb driver installed (and working) using
sudo pecl install mongo
however according to the pecl output this has been deprecated and replaced with
sudo pecl install mongodb
So I installed that, changed mongo.ini to load extension=mongodb.so instead of mongo.so (as instructed to by the output of the above pecl command) . When I load my phpinfo() page it shows that it is loaded
mongodb version 1.0.0
mongodb stability stable
libmongoc version 1.2.0
libbson version 1.2.0
However, when I try to use MongoClient in my PHP page, I get the following error:
Fatal error: Class 'MongoClient' not found in /srv/www/site/functions.php on line 500
I have exhausted all of the 'similar questions' suggested when creating this question, as well as google searches. So I'm hoping someone has some first-hand experience with fixing this because I feel like I'm out of options.
Turns out the class names have changed in the new driver. So MongoClient not existing is a valid error.
new MongoDB\Driver\Manager is the replacement for MongoClient
I have developed a PHP site using PHP 5.3.4 and deployed it to a server that has PHP 5.2.6 installed. I am not doing anything fancy; in fact, the only major library I am using is PHP's native SOAP library.
However, when I test my deployed site, I get the error:
Fatal error: Class 'SoapClient' not found in (path) on line 20
Are there any major differences between PHP 5.2.x and 5.3.x with respect to the SOAP library? I have already changed the configuration files. (Well, actually I told the sysadmin to do it, because I don't have permission to do so.) And I get the same error. Any ideas?
EDIT: More information...
I'm deploying my site to a Windows server.
The server has AppServ installed.
For some reason I don't understand, PHP's configuration file is C:\Windows\php.ini instead of PHP_DIR\php.ini.
I dont think soap is installed on the server try
sudo aptitude install php-soap
change the following line in php.ini:
;extension=php_soap.dll // before
extension=php_soap.dll // after
this enables the soap extension since PHP 5.0