Kin*_*ley 6 php persistence mongodb symfony doctrine-mongodb
我在使用http://symfony.com/doc/current/bundles/DoctrineMongoDBBundle/index.html上的doctrine mongodb cookbook将mongodb与Symfony(版本2.5.0-DEV)集成时遇到了一些问题.
对于'持久对象到MongoDB'阶段,一切都还可以.当我添加" $dm->persist($script);" 行时,我的远程数据库没有任何反应,我收到错误消息:
ClassNotFoundException:尝试从/var/www/Symfony/vendor/doctrine/mongodb/lib/Doctrine/MongoDB/Connection.php第283行中的全局命名空间加载类"Mongo".您是否忘记了此类的use语句?
但是如果没有持久性行,脚本会无错误地解析(但远程数据库没有任何反应).
这是我的Symfony版本(2.5.0)特有的,是否有解决方法?我在下面粘贴了我的整个脚本,包括use语句.任何帮助,将不胜感激 :).
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());
}
}
Run Code Online (Sandbox Code Playgroud)
多谢你们。现在可以工作了。扩展名 mongo.so 必须加载到 php.ini 中,并且我编辑了错误的 php.ini 文件。添加extension=mongo.so到位于/etc/php5/apache2/的 php.ini 中,现在它可以工作了:) 希望这可以帮助将来的人。
| 归档时间: |
|
| 查看次数: |
5585 次 |
| 最近记录: |