Maybe you need to use the Doctrine’s command line while you are developing a Symfony Bundle (or anything else).
This will make you able, for example, to validate the schema or to convert an annotated schema to its XML
counterpart.
Here is how to use Doctrine command line outside of a Symfony Application.
You have to simply create a cli-config.php
file and put it into the root directory of your developing bundle.
<?php
use Doctrine\ORM\Tools\Console\ConsoleRunner;
use Doctrine\ORM\Tools\Setup;
use Doctrine\ORM\EntityManager;
$paths = [getcwd() . "/Model"];
$isDevMode = true;
// the connection configuration
$dbParams = array( 'driver' => 'pdo_mysql',
'user' => 'root',
'password' => 'root',
'dbname' => 'test_your_bundle',
);
// @see http://stackoverflow.com/a/19129147/1399706
$config = Setup::createAnnotationMetadataConfiguration($paths, $isDevMode, null, null, false);
$entityManager = EntityManager::create($dbParams, $config);
return ConsoleRunner::createHelperSet($entityManager);
Now you can use vendor/bin/doctrine your:command
to perform the task you need.
Very simple! 🙂
Remember to “Make. Ideas. Happen.”.
I wish you flocking users, see you soon!
Leave a Reply