Php 如何在ZF和条令中生成模块模型?
我试图弄清楚如何为ZF中的模块生成模型?我的逻辑可能有缺陷,但设置如下: 我有一个模块的ZF结构设置。我有一个博客模块和一个游戏模块。我希望这两个系统彼此独立,但共享相同的通用模块,例如用户帐户,它们将托管在单独的数据库下,即Php 如何在ZF和条令中生成模块模型?,php,zend-framework,doctrine,models,Php,Zend Framework,Doctrine,Models,我试图弄清楚如何为ZF中的模块生成模型?我的逻辑可能有缺陷,但设置如下: 我有一个模块的ZF结构设置。我有一个博客模块和一个游戏模块。我希望这两个系统彼此独立,但共享相同的通用模块,例如用户帐户,它们将托管在单独的数据库下,即博客数据库和游戏数据库以及核心数据库。因此,我的结构如下所示: ZF / - applications / - configs - controllers - models User.php - modules - blog
博客数据库
和游戏数据库
以及核心数据库
。因此,我的结构如下所示:
ZF /
- applications /
- configs
- controllers
- models
User.php
- modules
- blog
- controllers
- models
Blog.php
- views
- games
- controllers
- models
Games.php
- views
- views
我只是对如何让条令为单个模块生成模型有点困惑。我可能完全错误地看待这一点,如果有人能提供一些见解,我将非常感激,除了手动操作。回到尝试做更多的研究,看看我是否能找到解决方案
谢谢。如果您不能按自己的方式生成它们:(,很抱歉。 我以前也遇到过同样的问题,我认为最好的解决方案是从应用程序文件夹中生成模型,并将它们放入库文件夹中,这样结构就会更简单
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
因此,您的所有模型都具有相同的前缀+节省了手动编辑每个生成的模型以适应其名称空间的时间和痛苦
在我的下面
<?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']);
?>
谢谢你这么说,就像我想的那样。在我完全放弃之前,我有一些其他的想法,关于我自己的自定义
原则\u Cli
。但是谢谢你为我确认这一点。非常感谢。