简体   繁体   English

在Connection.php Symfony 2中找不到Mongo类

[英]Unable to find Mongo class in Connection.php Symfony 2

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. 我在mongo DB上有一个symfony 2。 I have set up my composer.json file to download doctrine-mongo and doctrine-mongo-bundle, 我已经设置了composer.json文件来下载doctrine-mongo和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. 为了下载这2个模块,我需要在PHP中安装mongo扩展。 I have both of them, mongo and mongodb, installed via brew 我有两个,分别是通过brew安装的mongo和mongodb

brew install php56-mongo
brew install php56-mongodb

I believe I have mongo extensions allowed as well, since when I write 我相信我也允许mongo扩展,因为当我写

php -m

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. 然后您可以在那里看到mongo。

Also php -i returns info that mongo is enabled. php -i还返回启用mongo的信息。

But when I'm trying to hit app_dev.php file in my project, I still get this: 但是当我尝试在我的项目中点击app_dev.php文件时,我仍然得到以下信息:

ClassNotFoundException in Connection.php line 284: Attempted to load class "Mongo" from the global namespace. Connection.php第284行中的ClassNotFoundException:尝试从全局名称空间中加载类“ Mongo”。 Did you forget a "use" statement? 您是否忘记了“使用”声明?

I'm using a Mac OS X and have chmod 777 on 我正在使用Mac OS X,并在chmod 777上

app/logs
app/cache 
web/

recursively. 递归地

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. PHP Cli和fpm / apache没有使用相同的配置,这意味着您的php -m可能不准确。

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. 您可以做的是在服务器上php入口点文件内调用http://php.net/manual/en/function.extension-loaded.php并确保已加载它。 Restarting the processes can help as well. 重新启动过程也可以有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM