Doctrine 2命令行打印Cygwin配置

Fel*_*rre 4 php doctrine doctrine-orm

我试图在我的项目中使用Doctrine 2,但当我尝试访问命令行从我的数据库导入实体以生成文件时,它会打印来自我的代码 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" "$@"
Run Code Online (Sandbox Code Playgroud)

我的文件夹结构:

src/
vendor/
bootstrap.php
cli-config.php
composer.json
composer.lock
index.php
Run Code Online (Sandbox Code Playgroud)

bootstrap.php中

<?php

require_once "vendor/autoload.php";

use Doctrine\ORM\Tools\Setup;
use Doctrine\ORM\EntityManager;

$paths = array("src/Entity");
$isDevMode = false;

// the connection configuration
$dbParams = array(
    'driver'   => 'pdo_mysql',
    'user'     => '',
    'password' => '',
    'dbname'   => '',
);

$config = Setup::createAnnotationMetadataConfiguration($paths, $isDevMode);
$entityManager = EntityManager::create($dbParams, $config);
Run Code Online (Sandbox Code Playgroud)

CLI-config.php文件

<?php

use Doctrine\ORM\Tools\Console\ConsoleRunner;

// replace with file to your own project bootstrap
require_once 'bootstrap.php';

// replace with mechanism to retrieve EntityManager in your app
$entityManager = GetEntityManager();

return ConsoleRunner::createHelperSet($entityManager);
Run Code Online (Sandbox Code Playgroud)

我试图在我的命令行中使用:php vendor/bin/doctrine --help.我也使用Vagrant和Ubuntu 14.01.

我没有使用Symfony 2,只是尝试在没有任何框架的情况下安装Doctrine.

谢谢.

小智 8

我在Windows安装程序中遇到同样的错误,这个命令解决了它:

php vendor/doctrine/orm/bin/doctrine.php orm:schema-tool:create
Run Code Online (Sandbox Code Playgroud)

资料来源: http ://www.agevaled.com/2013/10/09/doctrine2-getting-started-issues/2147483647/