2010-11-18 1 views
0

저는 ZF에서 모듈 용 모델을 어떻게 생성하는지 알아 내려고하고 있습니까? 내 논리에 결함이있을 수 있지만 여기에 설정이 있습니다.ZF와 Doctrine에서 모듈 모델을 어떻게 생성합니까?

모듈 용 ZF 구조 설정이 있습니다. 블로그 모듈과 게임 모듈이 있습니다. 이 두 시스템이 서로 독립적이지만 사용자 계정과 같은 공통 모듈을 공유하기를 원한다면 별도의 데이터베이스 IE Blog DatabaseGame DatabaseCore database으로 호스트됩니다. 난 당신이 교리는 개별 모듈에 대한 모델을 생성하기 위해 얻을 수있는 방법에 조금 혼란 스러워요

ZF/
- applications/
    - configs 
    - controllers 
    - models 
     User.php 
    - modules 
    - blog 
     - controllers 
     - models 
      Blog.php 
     - views 
    - games 
     - controllers 
     - models 
      Games.php 
     - views 
    - views 

: 같은 내 구조가 보일 것이다. 누군가가 통찰력을 발휘할 수 있다면 완전히 잘못 생각할 수 있습니다. 수동으로 수행하지 않을 경우 완전히 감사 할 것입니다. 다시 한 가지 더 많은 연구를 해보기 위해 내가 해결책을 찾을 수 있는지 알아 봅니다.

감사합니다.

답변

1

AFAIK 당신은 당신의 방법으로 그들을 생성 할 수 없습니다. (미안 해요.) 나는 한 번 같은 문제에 부딪 혔고, 최선의 해결책은 응용 프로그램 폴더에서 모델을 생성하여 구조 때문에 라이브러리 폴더 그래서 모델 모두 같은 접두사 + 수동 네임 스페이스에 맞게 생성 된 각 모델을 편집하는 시간과 고통을 저장 할 것이다

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']); 
?> 
+1

감사합니다. 내가 생각한 것입니다. 나는 내 자신의 습관'Doctrine_Cli'에 대해 완전히 포기하기 전에 다른 아이디어를 가지고 있습니다. 그러나 나를 위해 이것을 확인해 주셔서 감사합니다. 고맙습니다. –

관련 문제