Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to configure doctrine command line tools on zenframework 2

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
like image 699
andreea115 Avatar asked Nov 25 '25 13:11

andreea115


1 Answers

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.

like image 103
Keyne Viana Avatar answered Nov 28 '25 17:11

Keyne Viana



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!