2012-01-09 31 views
2

我想要得到Doctrine2Zend Framework一起工作。到目前爲止,我已經能夠自動加載Doctrine2並連接到我的數據庫。根據架構聲明創建帶有Doctrine2的表和實體

我現在期待着在yml創建使用模式聲明我的表:

Doctrine\Entities\User: 
    type: entity 
    table: core_user 
    columns: 
     id: 
      primary: true 
      autoincrement: true 
      type: integer(11) 
      notnull: true 
     name: 
      type: string 
      notnull: true 
      default: '' 
     middle_name: 
      type: string 
      default: '' 
     last_name: 
      type: string 
      notnull:true 
      default: '' 
     username: 
      type: varchar(16) 
      default: '' 
     email: 
      type: string 
      notnull: true 
      default: '' 
     role_id: 
      type: integer 
     date_creation: 
      type: timestamp 
     version: 
      type: timestamp 

我已經能夠獲得命令行工作,但我不能讓它在創建表我數據庫。

我使用的是標準的Zend Framework文件夾結構

+-- Application 
     +-- configs 
     +-- controllers 
     +-- doctrine 
      +-- Schema 
       +-- schema.yml 
      +-- Entities 
      cli-config.php 
     +-- layouts 
     +-- models 
     +-- modules 
     +-- view 
     bootstrap.php 
+-- Public 
+-- Library 
     +-- Doctrine2 
+-- Tests 

我的模式聲明是在Application/doctrine/Schema/schema.yml,我期待的創建數據庫tables和我Entities從它。

當我嘗試運行命令doctrine orm:schema-tool:create時,出現以下消息:No Metadata Classes to process.我想知道爲什麼。

我在正確的方式得到它的工作,或者我應該手動定義我的實體,然後嘗試從它創建我的表?

回答

3

檢查cli-config.php中的配置。 你應該使用YAML司機:

// $config instanceof Doctrine\ORM\Configuration 
$driver = new YamlDriver(array('/path/to/files')); 
$config->setMetadataDriverImpl($driver); 

docs