PHP fatal error: class oauth still not found

2.3k views Asked by At

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.

1

There are 1 answers

0
acrazing On BEST ANSWER

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.