Reputation: 299
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
Upvotes: 3
Views: 8556
Reputation: 6202
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.
Upvotes: 3
Reputation: 16455
Once you have set up doctrine2 and zf2, you should be able to simply run all CLI commands.
php public/index.php orm:generate-entities
Using the parameters as described in the official documentation.
Note: DoctrineModule
and DoctrineORMModule
need to be enabled within your application.config.php
Upvotes: 2
Reputation: 750
You need to install the doctrine/doctrine-orm-module
with your Composer dependency manager. To do that, cd
to your web site's top-level directory and type the following command:
php composer.phar require doctrine/doctrine-orm-module *
After executing this command, the DoctrineModule
and DoctrineOrmModule
will be installed into your vendor
folder, and Doctrine commands will become available.
For more information about DoctrineOrmModule
, see this:
https://github.com/doctrine/DoctrineORMModule
Upvotes: 0