1

I would like to change the location of the doctrine cli-config.php file as well as possibly change it's name -- the first request is more important.

Any ideas???

Alex.Barylski
  • 2,843
  • 4
  • 45
  • 68
  • You must remove the file? I don't know if is what you need but you can make a copy via post command in the composer files, let me know if you need more info. Hope this help – Matteo Jun 08 '15 at 05:13
  • What is so specific about this file? Is it Doctrine internal? If so, do you have a link? What is your final goal? – Tomas Votruba Jun 08 '15 at 11:58
  • This file has to be in the root directory of your project - same as composer - or in a /config directory -- I would prefer to have it in a /scripts/cli-doctrine.php location – Alex.Barylski Jun 08 '15 at 12:44

2 Answers2

3

If you are using the doctrine CLI directly, this is not possible.

You can see this by having a look at the relevant source code:

$directories = array(getcwd(), getcwd() . DIRECTORY_SEPARATOR . 'config');
$configFile = null;
foreach ($directories as $directory) {
    $configFile = $directory . DIRECTORY_SEPARATOR . 'cli-config.php';
    if (file_exists($configFile)) {
        break;
    }
}

It only ever checks for cli-config.php and config/cli-config.php.


The alternative is to implement a CLI based on the Symfony Console component (which is what the Doctrine CLI is based on) yourself, and pull in the Doctrine commands. This allows you to avoid having cli-config.php altogether at the cost of having to put in a not-insignificant amount of work. You can find the details of this approach in this answer.

Community
  • 1
  • 1
Clamburger
  • 617
  • 6
  • 24
0

Exists another one approach. You can add in custom location file, for example cli.php(with your own file name). Than add in this file something like that:

```

<?php
// cli.php
// where your entityManager is created
require_once "bootstrap.php";

$helperSet = new \Symfony\Component\Console\Helper\HelperSet(array(
    'em' => new \Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper($entityManager)
));

\Doctrine\ORM\Tools\Console\ConsoleRunner::run($helperSet);

```

And you can run this file from where you want like php cli.php.

zey_ser
  • 155
  • 3
  • 11