我尝试从composer安装doctrine2 orm,它成功了,我设置了我的bootstrap.php,如下所示
<?php
define('DS', DIRECTORY_SEPARATOR);
define('ROOT', dirname(dirname(__FILE__)));
// bootstrap.php
require_once "vendor/autoload.php";
use Doctrine\ORM\Tools\Setup;
use Doctrine\ORM\EntityManager;
$paths = array(ROOT.DS.'library'.DS.'doctrine/entities/');
$isDevMode = false;
// the connection configuration
$dbParams = array(
'driver' => 'pdo_mysql',
'user' => 'root',
'password' => '',
'dbname' => 'meso',
);
$config = Setup::createAnnotationMetadataConfiguration($paths, $isDevMode);
$entityManager = EntityManager::create($dbParams, $config);
?>
这是我的 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);
?>
当我尝试在 cli 上使用以下命令将 orm 映射创建到我的实体文件夹中时,它会引发此错误“在第 8 行的 cli-config.php 中调用 GetEntityManager() 中的未定义函数”
> php vendor/doctrine/orm/bin/doctrine orm:convert-mapping xml ./path/to/entities/