This is quite an often occurring error, but since I tried a lot of stuff to fix it, I'm kind of getting out of the ideas.
I have a symfony 2 with mongo DB. I have set up my composer.json file to download doctrine-mongo and doctrine-mongo-bundle,
"doctrine/mongodb-odm": "1.0.*@beta", "doctrine/mongodb-odm-bundle": "3.0.*@beta",
In order to download this 2 modules, I needed to have mongo extension installed into PHP. I have both of them, mongo and mongodb, installed via brew
brew install php56-mongo brew install php56-mongodb
I believe I have mongo extensions allowed as well, since when I write
I get this results
[PHP Modules] bcmath bz2 calendar Core ctype curl date dba dom ereg exif fileinfo filter ftp gd gettext hash iconv json ldap libxml mbstring mhash mongo mongodb mysql mysqli mysqlnd odbc openssl pcntl pcre PDO pdo_mysql PDO_ODBC pdo_sqlite Phar posix readline Reflection session shmop SimpleXML soap sockets SPL sqlite3 standard sysvmsg sysvsem sysvshm tokenizer wddx xml xmlreader xmlrpc xmlwriter xsl zip zlib
and you can see mongo there.
Also php -i returns info that mongo is enabled.
But when I'm trying to hit app_dev.php file in my project, I still get this:
ClassNotFoundException in Connection.php line 284: Attempted to load class "Mongo" from the global namespace. Did you forget a "use" statement?
I'm using a Mac OS X and have chmod 777 on
app/logs app/cache web/
Do you have any idea what can trigger this ? Thank you.
PHP Cli and fpm/apache doesn't use the same configuration, which means your
php -m may be not accurate.
What you can do is call http://php.net/manual/en/function.extension-loaded.php inside your php entry point file on your server and make sure its loaded. Restarting the processes can help as well.