Skip to content

Instantly share code, notes, and snippets.

@immutef
Created October 16, 2010 18:50
Show Gist options
  • Save immutef/630152 to your computer and use it in GitHub Desktop.
Save immutef/630152 to your computer and use it in GitHub Desktop.
Latest Symfony2 Fixtures for Doctrine2
<?php // src/Application/GameBundle/DataFixtures/ORM/LoadGameData.php
// cd src/vendor && git clone git://github.com/doctrine/data-fixtures doctrine-data-fixtures
// register the "Doctrine\Common\DataFixtures" namespace in your src/autoload.php file
namespace Application\GameBundle\DataFixtures\ORM;
use Doctrine\ORM\EntityManager,
Doctrine\Common\DataFixtures\FixtureInterface;
use Application\GameBundle\Entity\Game;
class LoadGameData implements FixtureInterface
{
public function load($manager)
{
// first fixture ...
$game1 = new Game();
$game1->setFoo('bar');
$manager->persist($game1);
// add more fixtures ...
$manager->flush();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment