0
votes

My new PHP 7 install loads and plays nice with the mongodb driver at the command line.

But when I try to view the same resource as a Web page, the driver fails to load (and I get the attendant error(s) that go with that failure, pe: Class 'MongoDB\Driver\Query' not found").

At a loss as to why Apache, php, and the mongodb driver aren't working together. Here's the deets:

I'm running Apache 2.4.18...

httpd -v

Server version: Apache/2.4.18 (Amazon)
Server built:   Mar  7 2016 22:32:11

And PHP 7.0.6 (remi repo)...

PHP cli

PHP 7.0.6 (cli) (built: Apr 28 2016 21:34:10) ( NTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
    with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies
    with Xdebug v2.4.0, Copyright (c) 2002-2016, by Derick Rethans

phpinfo() confirms: version, php.ini location, and extension_dir are where I'd expect to find them...

phpinfo()

PHP Version 7.0.6
Loaded Configuration File /etc/opt/remi/php70/php.ini
extension_dir /opt/remi/php70/root/usr/lib64/php/modules

I've added the extension to the loaded ini file...

/etc/opt/remi/php70/php.ini

[mongo]
extension=mongodb.so

I've confirmed the lib for that extension is where php expects it to be...

ls -la /opt/remi/php70/root/usr/lib64/php/modules/mongodb.so

[redacted] /opt/remi/php70/root/usr/lib64/php/modules/mongodb.so

pecl says PEAR is up to date...

pecl help version

PEAR Version: 1.10.1
PHP Version: 7.0.6
Zend Engine Version: 3.0.0

yum install php70-php-pecl-mongodb

Loaded plugins: update-motd, upgrade-helper
Resolving Dependencies
--> Running transaction check
---> Package php70-php-pecl-mongodb.x86_64 0:1.1.6-2.el7.remi will be installed
--> Processing Dependency: mongo-c-driver(x86-64) >= 1.3.5 for package: php70-php-pecl-mongodb-1.1.6-2.el7.remi.x86_64
--> Processing Dependency: libbson-1.0.so.0(LIBBSON_1.2)(64bit) for package: php70-php-pecl-mongodb-1.1.6-2.el7.remi.x86_64
--> Processing Dependency: libbson-1.0.so.0(LIBBSON_1.1)(64bit) for package: php70-php-pecl-mongodb-1.1.6-2.el7.remi.x86_64
--> Processing Dependency: libbson-1.0.so.0(LIBBSON_1.0)(64bit) for package: php70-php-pecl-mongodb-1.1.6-2.el7.remi.x86_64
--> Processing Dependency: libsasl2.so.3()(64bit) for package: php70-php-pecl-mongodb-1.1.6-2.el7.remi.x86_64
--> Processing Dependency: libmongoc-priv.so.0()(64bit) for package: php70-php-pecl-mongodb-1.1.6-2.el7.remi.x86_64
--> Processing Dependency: libbson-1.0.so.0()(64bit) for package: php70-php-pecl-mongodb-1.1.6-2.el7.remi.x86_64
--> Running transaction check
---> Package mongo-c-driver.x86_64 0:1.3.5-1.el7.remi will be installed
--> Processing Dependency: mongo-c-driver-libs(x86-64) = 1.3.5-1.el7.remi for package: mongo-c-driver-1.3.5-1.el7.remi.x86_64
--> Processing Dependency: libbson-1.0.so.0()(64bit) for package: mongo-c-driver-1.3.5-1.el7.remi.x86_64
---> Package php70-php-pecl-mongodb.x86_64 0:1.1.6-2.el7.remi will be installed
--> Processing Dependency: libbson-1.0.so.0(LIBBSON_1.2)(64bit) for package: php70-php-pecl-mongodb-1.1.6-2.el7.remi.x86_64
--> Processing Dependency: libbson-1.0.so.0(LIBBSON_1.1)(64bit) for package: php70-php-pecl-mongodb-1.1.6-2.el7.remi.x86_64
--> Processing Dependency: libbson-1.0.so.0(LIBBSON_1.0)(64bit) for package: php70-php-pecl-mongodb-1.1.6-2.el7.remi.x86_64
--> Processing Dependency: libsasl2.so.3()(64bit) for package: php70-php-pecl-mongodb-1.1.6-2.el7.remi.x86_64
--> Processing Dependency: libmongoc-priv.so.0()(64bit) for package: php70-php-pecl-mongodb-1.1.6-2.el7.remi.x86_64
--> Processing Dependency: libbson-1.0.so.0()(64bit) for package: php70-php-pecl-mongodb-1.1.6-2.el7.remi.x86_64
--> Finished Dependency Resolution
Error: Package: php70-php-pecl-mongodb-1.1.6-2.el7.remi.x86_64 (remi-safe)
           Requires: libbson-1.0.so.0(LIBBSON_1.2)(64bit)
Error: Package: php70-php-pecl-mongodb-1.1.6-2.el7.remi.x86_64 (remi-safe)
           Requires: libsasl2.so.3()(64bit)
Error: Package: php70-php-pecl-mongodb-1.1.6-2.el7.remi.x86_64 (remi-safe)
           Requires: libbson-1.0.so.0()(64bit)
Error: Package: mongo-c-driver-1.3.5-1.el7.remi.x86_64 (remi-safe)
           Requires: libbson-1.0.so.0()(64bit)
Error: Package: php70-php-pecl-mongodb-1.1.6-2.el7.remi.x86_64 (remi-safe)
           Requires: libmongoc-priv.so.0()(64bit)
Error: Package: php70-php-pecl-mongodb-1.1.6-2.el7.remi.x86_64 (remi-safe)
           Requires: libbson-1.0.so.0(LIBBSON_1.0)(64bit)
Error: Package: mongo-c-driver-1.3.5-1.el7.remi.x86_64 (remi-safe)
           Requires: mongo-c-driver-libs(x86-64) = 1.3.5-1.el7.remi
Error: Package: php70-php-pecl-mongodb-1.1.6-2.el7.remi.x86_64 (remi-safe)
           Requires: libbson-1.0.so.0(LIBBSON_1.1)(64bit)
 You could try using --skip-broken to work around the problem
 You could try running: rpm -Va --nofiles --nodigest

rpm -qa php* | sort

php70-1.0-4.el6.remi.x86_64
php70-php-cli-7.0.6-3.el6.remi.x86_64
php70-php-common-7.0.6-3.el6.remi.x86_64
php70-php-devel-7.0.6-3.el6.remi.x86_64
php70-php-fpm-7.0.6-3.el6.remi.x86_64
php70-php-gd-7.0.6-3.el6.remi.x86_64
php70-php-json-7.0.6-3.el6.remi.x86_64
php70-php-mbstring-7.0.6-3.el6.remi.x86_64
php70-php-mcrypt-7.0.6-3.el6.remi.x86_64
php70-php-mysqlnd-7.0.6-3.el6.remi.x86_64
php70-php-opcache-7.0.6-3.el6.remi.x86_64
php70-php-pdo-7.0.6-3.el6.remi.x86_64
php70-php-pear-1.10.1-4.el6.remi.noarch
php70-php-pecl-amqp-1.7.0-1.el6.remi.x86_64
php70-php-pecl-apcu-5.1.4-1.el6.remi.x86_64
php70-php-pecl-apcu-bc-1.0.3-1.el6.remi.x86_64
php70-php-pecl-apcu-devel-5.1.4-1.el6.remi.x86_64
php70-php-pecl-apfd-1.0.1-5.el6.remi.x86_64
php70-php-pecl-apm-2.1.1-1.el6.remi.x86_64
php70-php-pecl-bitset-3.0.0-1.el6.remi.x86_64
php70-php-pecl-cassandra-1.1.0-1.el6.remi.x86_64
php70-php-pecl-couchbase2-2.2.0-0.1.beta2.el6.remi.x86_64
php70-php-pecl-crypto-0.2.2-1.el6.remi.x86_64
php70-php-pecl-eio-2.0.0-0.4.RC3.el6.remi.x86_64
php70-php-pecl-env-0.2.1-1.el6.remi.x86_64
php70-php-pecl-ev-1.0.0-1.el6.remi.x86_64
php70-php-pecl-event-2.0.4-1.el6.remi.x86_64
php70-php-pecl-fann-1.1.0-1.el6.remi.x86_64
php70-php-pecl-gender-1.1.0-6.el6.remi.x86_64
php70-php-pecl-geoip-1.1.0-9.el6.remi.x86_64
php70-php-pecl-geospatial-0.1.0-1.el6.remi.x86_64
php70-php-pecl-hprose-1.6.4-1.el6.remi.x86_64
php70-php-pecl-hrtime-0.5.1-6.el6.remi.x86_64
php70-php-pecl-http-3.0.1-1.el6.remi.x86_64
php70-php-pecl-http-devel-3.0.1-1.el6.remi.x86_64
php70-php-pecl-igbinary-1.2.2-0.1.20151217git2b7c703.el6.remi.x86_64
php70-php-pecl-igbinary-devel-1.2.2-0.1.20151217git2b7c703.el6.remi.x86_64
php70-php-pecl-inotify-2.0.0-1.el6.remi.x86_64
php70-php-pecl-json-post-1.0.1-3.el6.remi.x86_64
php70-php-pecl-libsodium-1.0.6-1.el6.remi.x86_64
php70-php-pecl-lua-2.0.1-1.el6.remi.x86_64
php70-php-pecl-lzf-1.6.5-1.el6.remi.x86_64
php70-php-pecl-mailparse-3.0.1-1.el6.remi.x86_64
php70-php-pecl-memcache-3.0.9-0.2.20151130gitfdbd46b.el6.remi.x86_64
php70-php-pecl-memcached-3.0.0-0.1.20160217git6ace07d.el6.remi.x86_64
php70-php-pecl-mogilefs-0.9.3.1-1.el6.remi.x86_64
php70-php-pecl-msgpack-2.0.1-1.el6.remi.x86_64
php70-php-pecl-msgpack-devel-2.0.1-1.el6.remi.x86_64
php70-php-pecl-mysql-1.0.0-0.9.20151007git294ce3b.el6.remi.x86_64
php70-php-pecl-oauth-2.0.1-1.el6.remi.x86_64
php70-php-pecl-pcs-1.3.1-1.el6.remi.x86_64
php70-php-pecl-pcs-devel-1.3.1-1.el6.remi.x86_64
php70-php-pecl-propro-2.0.0-1.el6.remi.x86_64
php70-php-pecl-propro-devel-2.0.0-1.el6.remi.x86_64
php70-php-pecl-radius-1.4.0-0.1.b1.el6.remi.x86_64
php70-php-pecl-raphf-2.0.0-1.el6.remi.x86_64
php70-php-pecl-raphf-devel-2.0.0-1.el6.remi.x86_64
php70-php-pecl-redis-2.2.8-0.6.20160504gitad3c116.el6.remi.x86_64
php70-php-pecl-rrd-2.0.1-1.el6.remi.x86_64
php70-php-pecl-scrypt-1.4-1.el6.remi.x86_64
php70-php-pecl-seaslog-1.5.3-1.el6.remi.x86_64
php70-php-pecl-selinux-0.4.1-6.el6.remi.x86_64
php70-php-pecl-solr2-2.4.0-1.el6.remi.x86_64
php70-php-pecl-ssdeep-1.0.4-9.el6.remi.x86_64
php70-php-pecl-stats-2.0.1-1.el6.remi.x86_64
php70-php-pecl-swoole-1.8.5-1.el6.remi.x86_64
php70-php-pecl-taint-2.0.1-1.el6.remi.x86_64
php70-php-pecl-trader-0.4.0-2.el6.remi.x86_64
php70-php-pecl-uopz-5.0.1-1.el6.remi.x86_64
php70-php-pecl-uploadprogress-1.0.3.1-11.el6.remi.x86_64
php70-php-pecl-uuid-1.0.4-6.el6.remi.x86_64
php70-php-pecl-weakref-0.3.2-1.el6.remi.x86_64
php70-php-pecl-xattr-1.3.0-1.el6.remi.x86_64
php70-php-pecl-xdebug-2.4.0-1.el6.remi.x86_64
php70-php-pecl-xmldiff-1.1.2-6.el6.remi.x86_64
php70-php-pecl-xmldiff-devel-1.1.2-6.el6.remi.x86_64
php70-php-pecl-xxtea-1.0.11-1.el6.remi.x86_64
php70-php-pecl-yac-2.0.0-1.el6.remi.x86_64
php70-php-pecl-yaconf-1.0.1-1.el6.remi.x86_64
php70-php-pecl-yaconf-devel-1.0.1-1.el6.remi.x86_64
php70-php-pecl-yaf-3.0.2-1.el6.remi.x86_64
php70-php-pecl-yaml-2.0.0-0.6.RC7.el6.remi.x86_64
php70-php-pecl-yar-2.0.0-1.el6.remi.x86_64
php70-php-pecl-yaz-1.2.0-2.el6.remi.x86_64
php70-php-pecl-zip-1.13.2-1.el6.remi.x86_64
php70-php-pecl-zmq-1.1.3-1.el6.remi.x86_64
php70-php-process-7.0.6-3.el6.remi.x86_64
php70-php-xml-7.0.6-3.el6.remi.x86_64
php70-runtime-1.0-4.el6.remi.x86_64
php-cli-7.0.6-3.el6.remi.x86_64
php-common-7.0.6-3.el6.remi.x86_64
php-devel-7.0.6-3.el6.remi.x86_64
php-json-7.0.6-3.el6.remi.x86_64
php-pear-1.10.1-4.el6.remi.noarch
php-process-7.0.6-3.el6.remi.x86_64
php-xml-7.0.6-3.el6.remi.x86_64
1
Seems like error in your class autoloader. 'Class not found' is not same to 'driver not found'. Have you included all requirements into your web script?Andrew
I am having this issue. I do have the mongodb.so, its enabled on the php.ini, it is not showing on phpinfo(). The vendor files are there. Any idea?Pablo Palacios

1 Answers

0
votes

How have you installed mongodb extension ?

You should not have to edit php.ini.

The php70-php-pecl-mongodb RPM provides its configuration file /etc/opt/remi/php70/php.d/50-mongodb.ini.

What is the output of "php70 -v" and "php70 -m" ?