0

我决定在 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 样式子目录?

4

1 回答 1

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' => ''
    ));
}
于 2012-04-05T12:02:09.530 回答