我想弄清楚如何在ZF中为模块生成模型?我的逻辑可能有缺陷,但这是设置:
我有模块的ZF结构设置。我有一个博客模块和一个游戏模块。我希望这两个系统彼此独立,但共享相同的通用模块,例如用户帐户,它们将托管在单独的数据库IE Blog Database
和Game Database
以及{ {1}}。所以我的结构看起来像:
Core database
我对如何获得学说为单个模块生成模型感到有点困惑。我可能会看到这完全错误,如果有人能够提供一些见解我会完全欣赏它,而不是手动做它。回到尝试做一些更多的研究,看看我是否能找到解决方案。
感谢。
答案 0 :(得分:1)
AFAIK你不能以你的方式生成它们:(对不起。 我之前遇到过同样的问题,我认为最好的解决方案是从应用程序文件夹中生成模型并将它们放入Library文件夹,这样结构就是
ZF /
- applications /
- configs
- controllers
- models
- modules
- blog
- controllers
- models
- views
- games
- controllers
- models
- views
- views
-library/
-your_custom_namespace
-Model
User.php
Blog.php
Games.php
所以你的所有模型都有相同的前缀+节省了手动编辑每个生成的模型以适应其命名空间的时间和痛苦。
低于我的学说cli
<?php
echo "Hello Tawfek ! , Howdy ?? \n";
/**
* Doctrine CLI
*/
error_reporting(E_ALL);
define('ROOT_PATH', realpath(dirname(__FILE__)));
define('APPLICATION_PATH', realpath(dirname(__FILE__) . "/../"));
define('APPLICATION_ENV', 'development');
//Ensure library/ is on include_path
set_include_path(implode(PATH_SEPARATOR, array(
'../library',get_include_path(), "/home/Sites/site/library/" )));
/** Zend_Application */
require_once 'Zend/Application.php';
// Create application, bootstrap, and run
$application = new Zend_Application(
APPLICATION_ENV,
APPLICATION_PATH . '/configs/application.ini'
);
// Read in the application.ini bootstrap for Doctrine
$application->getBootstrap()->bootstrap('doctrine');
// Create the configuration array
$config = $application->getOption('doctrine');
// (Note you can have all of these in application.ini aswell)
$config['generate_models_options'] = array(
// Define the PHPDoc Block in the generated classes
'phpDocPackage' =>'site',
'phpDocSubpackage' =>'Models',
'phpDocName' =>'Your Name Goes here',
'phpDocEmail' =>'Your Email',
'phpDocVersion' =>'1.0',
// Define whats what and named how, where.
'suffix' => '.php',
'pearStyle' => true,
'baseClassPrefix' => 'Base_',
// Unless you have created a custom class or want Default_Model_Base_Abstract
'baseClassName' => 'Doctrine_Record',
// Leave this empty as specifying 'Base' will create Base/Base
'baseClassesDirectory' => NULL,
// Should make it Zend Framework friendly AFAIK
'classPrefix' => 'Dagho_Model_',
'classPrefixFiles' => false,
'generateBaseClasses' => true,
'generateTableClasses' => false,
'packagesPath' => APPLICATION_PATH "/../library/Dagho/Model" ,
'packagesFolderName' => 'packages',
);
$cli = new Doctrine_Cli($config);
$cli->run($_SERVER['argv']);
?>