ClassNotFoundException:尝试加载类"Mongo".来自...(与坚持)symfony2 [英] ClassNotFoundException: Attempted to load class "Mongo" from... (with persist) symfony2
问题描述
我在使用一切正常,直到将对象保留到MongoDB"阶段为止.当我添加"$dm->persist($script);
"行时,远程数据库没有任何反应,并且收到错误消息:
Everything is okay up to the 'Persisting Objects to MongoDB' stage. When I add the line "$dm->persist($script);
", nothing happens to my remote database and I get the error message:
ClassNotFoundException:尝试从/var/www/Symfony/vendor/doctrine/mongodb/lib/Doctrine/MongoDB/Connection.php第283行中的全局命名空间加载类"Mongo".此类的陈述吗?
但是如果没有持久行,该脚本将进行解析而不会发生错误(但远程数据库没有任何反应).
But without the persist line, the script parses without errors (but nothing happens at the remote database).
这是我的Symfony版本(2.5.0)所特有的,是否有解决方法?我在下面粘贴了整个脚本,包括use语句.任何帮助,将不胜感激 :).
Is this particular to my Symfony version (2.5.0) and is there a workaround? I have pasted my entire script below including the use statements. Any help would be appreciated :).
namespace Atlas\MpBundle\Controller;
use Atlas\MpBundle\Document\Scripts;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\JsonResponse;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
class UserjsonController extends Controller
{
public function showuserjsonAction()
{
$script = new Scripts();
$script->setName('kingstest');
$script->setDescription('just a desc test');
$script->setGroup('SMS');
$dm = $this->get('doctrine_mongodb')->getManager();
$dm->persist($script);
$dm->flush();
return new Response('Created New Document in scripts with script id '.$script->getId());
}
}
推荐答案
谢谢大家.现在可以使用.
扩展名mongo.so必须加载到php.ini中,并且我编辑了错误的php.ini文件.在/etc/php5/apache2/中的php.ini中添加了extension=mongo.so
,现在可以使用了:)
希望这可以在将来对某人有所帮助.
Thanks guys. Works now.
the extension mongo.so has to be loaded in php.ini and I edited the wrong php.ini file. Added extension=mongo.so
to php.ini located in /etc/php5/apache2/ and now it works :)
Hopefully this can help someone in the future.
这篇关于ClassNotFoundException:尝试加载类"Mongo".来自...(与坚持)symfony2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!