原则 2 命令行配置作为外部库



我尝试将原则 2 配置为我的项目的外部库。因此,我通过Composer安装了它,并按照Doctrine文档上的说明进行操作。命令行不起作用。

这是我的引导中关于教义的部分:

use DoctrineORMToolsSetup;
use DoctrineORMEntityManager;
/* Instantiation of doctrine
 ---------------------------------------------------------------------------------------------------------------------*/
$paths = array(__DIR__."/Application/Entity");
$isDevMode = true;
// the connection configuration
$dbParams = Yaml::parse(file_get_contents('Application/Config/Private/bdd.yml'));
$config = Setup::createAnnotationMetadataConfiguration($paths, $isDevMode);
$em = EntityManager::create($dbParams, $config);
/*--------------------------------------------------------------------------------------------------------------------*/

这是我的 cli-config.php 文件(在项目根目录中(的内容:

use DoctrineORMToolsConsoleConsoleRunner;
require_once 'index.php'; // my bootstrap

return ConsoleRunner::createHelperSet($em);

所以,现在,文档说我可以通过键入以下内容在控制台模式下使用 Doctrine:php vendor/bin/doctrine但是,当我使用此命令时,它不会执行。我只有教义文件的内容:

dir=$(d=${0%[/\]*}; cd "$d"; cd "../doctrine/orm/bin" && pwd)
# See if we are running in Cygwin by checking for cygpath program
if command -v 'cygpath' >/dev/null 2>&1; then
        # Cygwin paths start with /cygdrive/ which will break windows PHP,
        # so we need to translate the dir path to windows format. However
        # we could be using cygwin PHP which does not require this, so we
        # test if the path to PHP starts with /cygdrive/ rather than /usr/bin
        if [[ $(which php) == /cygdrive/* ]]; then
                dir=$(cygpath -m "$dir");
        fi
fi
dir=$(echo $dir | sed 's/ / /g')
"${dir}/doctrine" "$@"

php工作正常,我尝试安装一个symfony项目(测试命令行(和命令行与Symfony一起工作。所以,我认为问题来自教义的安装/配置。

我不知道我错过了什么,但我不能通过命令行使用教义。有人有想法吗?

你调用的 doctrine 命令不是 PHP 文件,而是一个 shell 脚本。

改为调用./vendor/bin/doctrine,它应该按预期工作。

最新更新