I am having some issue integrating mongodb with Symfony (version 2.5.0-DEV) using the doctrine mongodb cookbook on http://symfony.com/doc/current/bundles/DoctrineMongoDBBundle/index.html.
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: Attempted to load class "Mongo" from the global namespace in /var/www/Symfony/vendor/doctrine/mongodb/lib/Doctrine/MongoDB/Connection.php line 283. Did you forget a use statement for this class?
But without the persist line, the script parses without errors (but nothing happens at the remote database).
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());
}
}