http://symfony.com/doc/current/bundles/DoctrineMongoDBBundle/index.htmlの doctrine mongodb cookbook を使用して、mongodb を Symfony (バージョン 2.5.0-DEV) に統合する際に問題が発生しています。
「MongoDB へのオブジェクトの永続化」段階まではすべて問題ありません。" " という行を追加して$dm->persist($script);
も、リモート データベースには何も起こらず、次のエラー メッセージが表示されます。
ClassNotFoundException: Attempted to load class "Mongo" from the global namespace in /var/www/Symfony/vendor/doctrine/mongodb/lib/Doctrine/MongoDB/Connection.php 行 283. このクラスの use ステートメントを忘れましたか?
しかし、persist 行がなければ、スクリプトはエラーなしで解析します (ただし、リモート データベースでは何も起こりません)。
これは私の 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());
}
}