Created
September 17, 2015 20:32
-
-
Save caseyamcl/db86e1a28ad9fed96cce to your computer and use it in GitHub Desktop.
Entity Generator for Doctrine?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use Doctrine\ORM\Tools\Setup; | |
use Doctrine\ORM\EntityManager; | |
require_once "vendor/autoload.php"; | |
// Create a simple "default" Doctrine ORM configuration for Annotations | |
$isDevMode = true; | |
$config = Setup::createYAMLMetadataConfiguration(array(__DIR__), $isDevMode); | |
// database configuration parameters | |
$conn = array( | |
'driver' => 'pdo_sqlite', | |
'path' => __DIR__ . '/db.sqlite', | |
); | |
// obtaining the entity manager | |
$entityManager = EntityManager::create($conn, $config); | |
$mFactory = new \Doctrine\ORM\Tools\DisconnectedClassMetadataFactory(); | |
$mFactory->setEntityManager($entityManager); | |
$entityGenerator = new \Doctrine\ORM\Tools\EntityGenerator(); | |
// We need to build an instance of this: Doctrine\Common\Persistence\Mapping\ClassMetadata | |
$metadata = '....'; | |
$entityGenerator->setGenerateAnnotations(true); | |
$entityGenerator->setGenerateStubMethods(true); | |
$entityGenerator->setNumSpaces(4); | |
$entityGenerator->setAnnotationPrefix('ORM'); | |
$entityGenerator->setFieldVisibility('protected'); | |
$entityGenerator->generateEntityClass($metadata); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment