PHP Doctrine无法找到映射实体?

I am trying to setup XML mapping in doctrine. Whenever I go to create the database using the CLI orm:schema-tools:create it tells me:

[OK] No Metadata Classes to process.

Here is my code and folder structure:

    /public_html
        /Model
            User.php
        /xml
            Model.User.dcm.XML

        bootstrap.php
        register.php

    /vendor
    cli_config.php
    composer.json

bootstrap.php code:

    <?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 code:


    <?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 code:


    <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>

First time using stackoverflow so I hope I formatted this properly. Thanks!

dongzhou4727
dongzhou4727 弄清楚了。我的xml文件名为Model.User.dcm.XML,需要更改为Model.User.dcm.xml(小写xml)
大约一年之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐