Reputation: 310
I am currently trying to set up Doctrine with my Slim application.
I read this guide : http://busypeoples.github.io/post/slim-doctrine/. Everything is fine until i hit the Adding the Doctrine Commandline Tool part.
It explains that I need a doctrine_cli.php file in order to set up the command line tool, with this code inside :
<?php
require 'vendor/autoload.php';
$em = //Some code to create EntityManager
$helpers = 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)
));
Where should I create doctrine_cli.php ?
Thank you.
Upvotes: 1
Views: 1474
Reputation: 310
I found an answer some minutes ago. It may help someone in the future.
It appears that you can put the config file anywhere, as long as you execute the command line in the same directory.
You call the commandline tool this way (see Doctrine Documentation for reference) :
$ vendor/bin/doctrine orm:schema-tool:create
This calls a bash script in vendor/bin/
, wich calls doctrine.php
in vendor/doctrine/orm/bin/
.
In this file you can see this line :
$configFile = getcwd() . DIRECTORY_SEPARATOR . 'cli-config.php';
This means that :
cli-config.php
, and not doctrine_cli.php
.getcwd()
, wich refers to the directory you are into when you execute the command line.Create a cli-config.php file in any/path/you/want
(see Doctrine Documentation for reference).
<?php
require 'path/to/vendor/autoload.php';
$em = //Some code to create EntityManager
$helpers = 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)
));
Execute your command line tool in the same directory
$ cd any/path/you/want
any/path/you/want$ vendor/bin/doctrine orm:schema-tool:create
Edit :
For Doctrine 2.4, you can also put it in a directory named config
and execute the command line tool in config
parent directory
Upvotes: 2