how to configure doctrine command line tools on zenframework 2
command-line, doctrine-orm, zend-framework2
Solution
If you have started your project using the Zend Skeleton Application you do have a composer.json file. You just need to include the DoctrineORMModule (instructions here)
Then, using the CMD just type
C: > cd project-directory project-dir > vendor\bin\doctrine-module orm:validate-schema
There you go.
Problem
i am using doctrine 2 on zendframework 2. i have configured both correcly and they are both working. i however wish to use doctrine's command line tool to generate entities etc. i have followed doctrine's instructions and created a cli-config.php page in the root of my application: http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/configuration.html i am however lost on two issues; the configuration requires a bootstrap php page; however, zendframework 2 does not use a bootstrap page; so what would the equivalent be? Secondly, it requires us to obtain an entity mangager; would the method below be the correct way to get the entity manager: ``` public function getEntityManager() { if (null === $this->em) { $this->em = $this->getServiceLocator()->get('doctrine.entitymanager.orm_default'); } return $this->em; } ``` below is how the cli-config.php page should look; ``` // cli-config.php require_once 'my_bootstrap.php'; // Any way to access the EntityManager from your application $em = GetMyEntityManager(); $helperSet = new \Symfony\Component\Console\Helper\HelperSet(array( 'db' => new \Doctrine\DBAL\Tools\Console\Helper\ConnectionHelper($em->getConnection()), 'em' => new \Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper($em) )); ``` i would really appreciate any help or advice on this matter. warm regards Andreea the matter has been resolved:!! it did not work because i was using a cygdrive command line. however, when i switched to git bash it worked perfectly. with git bash i have to use the command: ``` C: > cd project-directory project-dir > vendor\bin\doctrine-module orm:validate-schema ```