I'm working on a Symfony project, and I'm trying to fill some fixtures data to mongoDB, that's what I did :
<?php
namespace FrontOfficeBundle\DataFixtures\ORM;
use FrontOfficeBundle\Document\Customer;
use Doctrine\Bundle\FixturesBundle\Fixture;
use Doctrine\Common\Persistence\ObjectManager;
class Fixtures extends Fixture
{
public function load(ObjectManager $manager)
{
$customer = new Customer();
$customer->setName("Ben Abdallah");
$customer->setSurename("Wajdi");
$customer->setUsername("wajdibenabdallah");
$customer->setEmail("wajdi.benabdallah@smarttouchtunisie.com");
$customer->setPhone("28812010");
$customer->setPassword("");
$manager->flush();
}
}
php bin/console doctrine:mongodb:fixtures:load
and then i got back these results :
Careful, database will be purged. Do you want to continue (y/N) ?y
> purging database
> loading Doctrine\Bundle\FixturesBundle\EmptyFixture
> loading FrontOfficeBundle\DataFixtures\ORM\Fixtures
But nothing has happened in the database (still empty).
I'am using :
Any ideas ? Thanks you.
You need to persist the $customer
object:
$manager->persist($customer); // Store in database.
Can you try that?