Last active
August 29, 2015 14:00
-
-
Save avandrevitor/3ab805c2a3f151a262f4 to your computer and use it in GitHub Desktop.
Paranauês Loucos com Doctrine Tools
This file contains 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 | |
require_once "vendor/autoload.php"; | |
use Doctrine\ORM\Tools\Setup; | |
use Doctrine\ORM\EntityManager; | |
$paths = array("./src/","./metadata/"); | |
$isDevMode = true; | |
// the connection configuration | |
$dbParams = array( | |
'driver' => 'pdo_mysql', | |
'user' => 'root', | |
'password' => '123456789', | |
'dbname' => 'test', | |
'charset' => 'utf8' | |
); | |
$config = Setup::createXMLMetadataConfiguration($paths, $isDevMode); | |
$entityManager = EntityManager::create($dbParams, $config); | |
#Fix type missing | |
$platform = $entityManager->getConnection()->getDatabasePlatform(); | |
$platform->registerDoctrineTypeMapping('enum', 'string'); | |
$platform->registerDoctrineTypeMapping('set', 'string'); | |
#Test Final | |
# Inicia o processo com $config = Setup::createXMLMetadataConfiguration($paths, $isDevMode); | |
# run php vendor/bin/doctrine orm:convert-mapping --force --from-database --namespace="Namespace\\Model\\" xml ./metadata/ | |
# adicione o atributo repository-class ao final da tag <entity> com o namespace do EntityRepository responsável por aquela entidade | |
# run php vendor/bin/doctrine orm:generate-entities --generate-annotations=1 --generate-methods=1 ./src/ | |
# run php vendor/bin/doctrine orm:generate:repositories ./src/ | |
# deleta os arquivos metadata *.xml | |
# substitui todos os inicios de comentarios com @ORM\ por => @ | |
# Apenas nas classes de modelo geradas |
This file contains 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 | |
# path config/cli-config.php | |
use Doctrine\ORM\Tools\Console\ConsoleRunner; | |
require_once dirname(dirname(__FILE__)).DIRECTORY_SEPARATOR.'bootstrap.php'; | |
return ConsoleRunner::createHelperSet($entityManager); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment