How do you generate Modules Models in ZF and Doctrine?
I am trying to figure out how do you generate models for modules in ZF? My logic could be flawed, but here is the setup:
I have a ZF Structure setup for modules. I have a Blog Module and a Game Module. I wi开发者_运维百科sh for both of these systems to be independent of each other, but share the same common modules, such as user accounts, they would be hosted under separate databases IE a Blog Database
and a Game Database
and a Core database
. So my structure would look like:
ZF /
- applications /
- configs
- controllers
- models
User.php
- modules
- blog
- controllers
- models
Blog.php
- views
- games
- controllers
- models
Games.php
- views
- views
I am just a bit confused on how you can get doctrine to generate the models for individual modules. I could be looking at this completely wrong, if anyone can shed some insight I would totally appreciate it, short of manually doing it. Back to trying to do some more research for it see if I can find the solution.
Thanks.
AFAIK you can't generate them in your way :( , sorry for that . i ran into same problem once before and i think the best solution is to generate the Models out of the application folder and put them into the Library folder so the structure would be
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
so all of your model would have the same prefix + save the time and pain of manually editing each generated model to fit to its namespace .
down below my doctrine 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']);
?>
精彩评论