Doctrine 默认 cli-config.php 位置
Doctrine default cli-config.php location
我想更改 doctrine cli-config.php 文件的位置并可能更改它的名称 -- 第一个请求更重要。
有什么想法吗???
如果您直接使用 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 (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 .
实施 CLI
存在另一种方法。您可以添加自定义位置文件,例如 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
。
我想更改 doctrine cli-config.php 文件的位置并可能更改它的名称 -- 第一个请求更重要。
有什么想法吗???
如果您直接使用 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 (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
存在另一种方法。您可以添加自定义位置文件,例如 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
。