2012-04-05 33 views
0

我已決定採納的Zend此目錄結構:學說1.2 + Zend的11.11:定義其中生成的類將被保存

application 
    doctrine 
     models 
      base 
     schema 
     //other Doctrine directories 
    controllers 
    models 
    services 
    views 

我也在此爲Doctrine_Cli的配置選項:

doctrine.cli_options.models_path = APPLICATION_PATH "/doctrine/models/" 
doctrine.cli_options.data_fixtures_path = APPLICATION_PATH "/doctrine/data/fixtures" 
doctrine.cli_options.sql_path = APPLICATION_PATH "/doctrine/data/sql" 
doctrine.cli_options.yaml_schema_path = APPLICATION_PATH "/doctrine/schema" 
doctrine.cli_options.migrations_path = APPLICATION_PATH "/doctrine/migrations" 
doctrine.cli_options.generate_models_options.generateTableClasses = true 
doctrine.cli_options.generate_models_options.generateBaseClasses = true 
doctrine.cli_options.generate_models_options.pearStyle = true 
doctrine.cli_options.generate_models_options.baseClassPrefix = 'Base_' 
doctrine.cli_options.generate_models_options.baseClassName = 'Doctrine_Record' 
doctrine.cli_options.generate_models_options.baseClassesDirectory = '' 
doctrine.cli_options.generate_models_options.classrefixFiles = false 
doctrine.cli_options.generate_models_options.classPrefix = 'Application_Doctrine_Model_' 

我還添加了一個資源到應用程序的命名空間從application/doctrine/models

我的問題是加載Application_Doctrine_Model_*文件,雖然根創建的模型是使用預期的前綴創建的,它們在application/doctrine/models/base目錄下自己的Application/ ..子目錄下生成。

結果是application/doctrine/models/Application/Doctrine/Models/...,因此,Zend的資源自動加載器找不到它們。

是否有Doctrine_Cli的配置選項來指定我想在application/doctrine/models下生成模型,但不生成新的Application/ .. PEAR樣式子目錄?

回答

1

更改classPrefix到:

doctrine.cli_options.generate_models_options.classPrefix = 'Model_' 

,你有錯字錯誤classrefixFiles

doctrine.cli_options.generate_models_options.classPrefixFiles = false 

加載生成的模型使用這種結構上的bootstrap.php中

public function _initLoaders() 
{ 
    new Zend_Application_Module_Autoloader(array(
     'basePath' => APPLICATION_PATH, 
     'namespace' => '' 
    )); 
} 
+0

這在'application/models/Models'下生成模型;但最重要的是這些類被命名爲'Model_ *',而不是'Application_Doctrine_Model_ *'。所以Zend依然看不到它們。 – 2012-04-05 13:46:00

+0

你有錯字classPrefixFiles,模型將在應用/模型下生成,前綴爲Model_ *,並由def加載 – 2012-04-05 13:52:55

+0

哦,男人。這是尷尬。感謝您指出一個。現在正在工作。 :) – 2012-04-06 08:08:57