-
Notifications
You must be signed in to change notification settings - Fork 233
Closed
Labels
Description
I'm using Symfony with MongoDB. I'm getting this error. Why? Please Help me!
app/config.yml
doctrine_mongodb:
connections:
default:
server: mongodb://localhost:27017
options: {}
default_database: test_database
document_managers:
default:
auto_mapping: true
Controller:
namespace fuar\sergiBundle\Controller;
use fuar\sergiBundle\Entity\Product;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Response;
class DefaultController extends Controller
{
public function indexAction()
{
$product = new Product();
$product->setName("xxx");
$product->setAge('25');
$product->setSchool("xxxx");
$dm = $this->get('doctrine_mongodb')->getManager();
$dm->persist($product);
$dm->flush();
return new Response('Created product id '.$product->getId());
}
}
fuar/sergiBundle/Entity/Product.php
namespace fuar\sergiBundle\Entity;
use Doctrine\ODM\MongoDB\Mapping\Annotations as MongoDB;
/**
* Product
*/
class Product
{
/**
* @var integer
*/
private $id;
/**
* @var string
*/
private $name;