我想更改doctrine cli-config.php文件的位置以及可能更改它的名称 - 第一个请求更重要。
任何想法???
答案 0 :(得分:2)
如果您直接使用doctrine CLI,则无法实现。
您可以通过查看相关的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;
}
}
它只检查cli-config.php
和config/cli-config.php
。
另一种方法是自己实现基于Symfony Console component(这是Doctrine CLI所基于的)的CLI,并引入Doctrine命令。这样可以避免以cli-config.php
为代价,不得不付出不小的工作量。您可以在this answer。
答案 1 :(得分:0)
存在另一种方法。您可以添加自定义位置文件,例如cli.php(具有自己的文件名)。比在此文件中添加以下内容:
```
<?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);
```
您可以从php cli.php
之类的位置运行此文件。