Last active
July 6, 2025 02:46
-
-
Save tawfekov/4079388 to your computer and use it in GitHub Desktop.
Revisions
-
tawfekov revised this gist
Dec 29, 2017 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -20,7 +20,7 @@ 'port' => '3306', 'user' => 'root', 'password' => 'root', 'dbname' => 'dbname', 'charset' => 'utf8', ); -
tawfekov created this gist
Nov 15, 2012 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,47 @@ <?php include '../vendor/autoload.php'; $classLoader = new \Doctrine\Common\ClassLoader('Entities', __DIR__); $classLoader->register(); $classLoader = new \Doctrine\Common\ClassLoader('Proxies', __DIR__); $classLoader->register(); // config $config = new \Doctrine\ORM\Configuration(); $config->setMetadataDriverImpl($config->newDefaultAnnotationDriver(__DIR__ . '/Entities')); $config->setMetadataCacheImpl(new \Doctrine\Common\Cache\ArrayCache); $config->setProxyDir(__DIR__ . '/Proxies'); $config->setProxyNamespace('Proxies'); $connectionParams = array( 'driver' => 'pdo_mysql', 'host' => 'localhost', 'port' => '3306', 'user' => 'root', 'password' => 'root', 'dbname' => 'adslmanager', 'charset' => 'utf8', ); $em = \Doctrine\ORM\EntityManager::create($connectionParams, $config); // custom datatypes (not mapped for reverse engineering) $em->getConnection()->getDatabasePlatform()->registerDoctrineTypeMapping('set', 'string'); $em->getConnection()->getDatabasePlatform()->registerDoctrineTypeMapping('enum', 'string'); // fetch metadata $driver = new \Doctrine\ORM\Mapping\Driver\DatabaseDriver( $em->getConnection()->getSchemaManager() ); $em->getConfiguration()->setMetadataDriverImpl($driver); $cmf = new \Doctrine\ORM\Tools\DisconnectedClassMetadataFactory($em); $cmf->setEntityManager($em); $classes = $driver->getAllClassNames(); $metadata = $cmf->getAllMetadata(); $generator = new Doctrine\ORM\Tools\EntityGenerator(); $generator->setUpdateEntityIfExists(true); $generator->setGenerateStubMethods(true); $generator->setGenerateAnnotations(true); $generator->generate($metadata, __DIR__ . '/Entities'); print 'Done!';