Skip to content

Instantly share code, notes, and snippets.

@tournasdim
Created April 29, 2014 07:22
Show Gist options
  • Save tournasdim/11392844 to your computer and use it in GitHub Desktop.
Save tournasdim/11392844 to your computer and use it in GitHub Desktop.
Doctrine 2 bootstrap file (defining explicitly the AnnotationDriver) Entities should now import the Mapper Classes : use Doctrine\ORM\Mapping as ORM ; /** * @Orm\Entity * @Orm\Table(name="blog") */ class Blog { /** * @Orm\Id * @Orm\Column(type="integer") * @Orm\GeneratedValue(strategy="AUTO") */ protected $id;
<?php
use Doctrine\ORM\Tools\Setup;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\Mapping\Driver\AnnotationDriver ;
use Doctrine\Common\Annotations\AnnotationReader ;
require_once __DIR__.'/../vendor/autoload.php';
require_once __DIR__.'/../config/config.php';
$entitiesPath = array(__DIR__.'/Blog');
$config = Setup::createAnnotationMetadataConfiguration($entitiesPath, $isDevMode);
$driver = new AnnotationDriver(new AnnotationReader(),array(__DIR__ . '/Blog'));
$config->setMetadataDriverImpl($driver);
$entityManager = EntityManager::create($dbParams, $config);
//var_dump($config) ; // Doctrine\ORM\Configuration
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment