我正在尝试在理论中设置XML映射。每当我使用CLI来创建数据库时,orm:schema-tools:create都会告诉我:
[确定]没有要处理的元数据类。
这是我的代码和文件夹结构:
/public_html
/Model
User.php
/xml
Model.User.dcm.XML
bootstrap.php
register.php
/vendor
cli_config.php
composer.json
bootstrap.php代码:
<?php
use Doctrine\ORM\EntityManager,
Doctrine\ORM\Configuration;
require_once __DIR__ . '/../vendor/autoload.php';
$isDevMode = true;
//set doctrine configurations
if ($isDevMode) {
$cache = new \Doctrine\Common\Cache\ArrayCache;
} else {
$cache = new \Doctrine\Common\Cache\ApcCache;
}
$config = new Configuration;
$config->setMetadataCacheImpl($cache);
$driverImpl = new \Doctrine\ORM\Mapping\Driver\XmlDriver(array(__DIR__ . '/xml/'));
$config->setMetadataDriverImpl($driverImpl);
$config->setQueryCacheImpl($cache);
$config->setProxyDir(__DIR__ . '/Proxy');
$config->setProxyNamespace('Proxy');
if ($isDevMode) {
$config->setAutoGenerateProxyClasses(true);
} else {
$config->setAutoGenerateProxyClasses(false);
}
// the connection configuration
$dbParams = array(
'dbname' => 'mafiaage_dev',
'user' => 'root',
'password' => 'pass',
'host' => '3x.x.x',
'driver' => 'pdo_mysql',
);
$em = EntityManager::create($dbParams, $config);
Model / User.php代码:
<?php
namespace Model;
Class User {
protected $id;
protected $name;
protected $password;
public function setName($name)
{
$this->name = $name;
}
public function setPassword($password)
{
$this->name = $password;
}
}
?>
xml / Model.User.dcm.XML代码:
<doctrine-mapping>
<entity name="Model\User">
<id name="id" type="integer" column="user_id">
<generator strategy="AUTO" />
</id>
<field name="name" type="string" />
<field name="password" type="string" />
</entity>
</doctrine-mapping>
第一次使用stackoverflow,所以希望我能正确格式化它。谢谢!