我在使用http://symfony.com/doc/current/bundles/DoctrineMongoDBBundle/index.html上的学说 mongodb 食谱将 mongodb 与 Symfony(版本 2.5.0-DEV)集成时遇到了一些问题。
在“持久化对象到 MongoDB”阶段之前一切正常。当我添加“ $dm->persist($script);
”行时,我的远程数据库没有任何反应,我收到错误消息:
ClassNotFoundException:尝试从 /var/www/Symfony/vendor/doctrine/mongodb/lib/Doctrine/MongoDB/Connection.php 第 283 行中的全局命名空间加载类“Mongo”。您忘记了该类的使用语句吗?
但如果没有persist 行,脚本解析不会出错(但远程数据库没有任何反应)。
这是我的 Symfony 版本(2.5.0)特有的吗?有解决方法吗?我在下面粘贴了我的整个脚本,包括使用语句。任何帮助,将不胜感激 :)。
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());
}
}