Doctrine 1.2 + Zend 11.11:定义生成的类的保存位置

时间:2012-04-05 10:03:11

标签: php zend-framework doctrine-1.2

我决定在Zend中采用这个目录结构:

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名称空间中添加了一个资源,以便从Application_Doctrine_Model_*

加载application/doctrine/models个文件

我的问题是,尽管生成的模型是使用预期的前缀创建的,但它们是在application/doctrine/models/base子目录下的Application/ ..目录下生成的。

结果为application/doctrine/models/Application/Doctrine/Models/...,因此,Zend的资源自动加载器无法找到它们。

是否有Doctrine_Cli的配置选项指定我想在application/doctrine/models下生成模型但不生成新的Application/ .. PEAR样式子目录?

1 个答案:

答案 0 :(得分: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' => ''
    ));
}