I agree with Ludek to let the ORM generate the database, that's what it's made for and does best. But you could try to get it working by adding an entry under 'External Tools' for the Doctrine command line tool (php doctrine orm:schema-tool:create
). This way you can generate the database (or SQL) using just a button from ORM Designer. I haven't tried it yet but I'll keep you posted on this if I get around to it.
EDIT :
After some playing around, I got it to work (sort of). This is what you should do:
- Install Doctrine2 (it's not even necessary to set up a complete project)
Create an entry in 'External Tools':
- Title:
Export SQL
- Command:
cmd /C php "C:/WAMP/www/doctrine2-master/bin/doctrine.php"
- Arguments:
orm:schema-tool:create --dump-sql 1> "export\SQL\schema-create.sql" 2>> "export\SQL\error.log"
- Initial Directory:
%PROJECT_DIRECTORY%
Create a Doctrine config file (cli-config.php
) in your project's main folder:
<?php
use Doctrine\Common\ClassLoader;
use Doctrine\Common\Annotations\AnnotationRegistry;
use Doctrine\Common\Annotations\AnnotationReader;
use Doctrine\ORM\Configuration;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\Mapping\Driver\AnnotationDriver;
use Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper;
use Symfony\Component\Console\Helper\HelperSet;
$includePath = realpath(__DIR__.'/export/Doctrine/PHP');
$classLoader = new ClassLoader('Application\Model\Entity', $includePath);
$classLoader->register();
$entityPaths = array(
$includePath.'/Application/Model/Entity'
);
AnnotationRegistry::registerFile('C:\WAMP\www\doctrine2-master\lib\Doctrine\ORM\Mapping\Driver\DoctrineAnnotations.php');
$reader = new AnnotationReader();
$driverImpl = new AnnotationDriver($reader, $entityPaths);
$config = new Configuration();
$config->setProxyDir(__DIR__ . '/Application/Model/Proxies');
$config->setProxyNamespace('Proxies');
$config->setMetadataDriverImpl($driverImpl);
$conn = array(
'driver' => 'pdo_mysql',
//'host' => 'localhost',
//'dbname' => '***',
//'user' => '***',
//'password' => '***',
);
$helperSet = new HelperSet(array(
'em' => new EntityManagerHelper(EntityManager::create($conn, $config))
));