2010-11-18 9 views
0

Ich versuche herauszufinden, wie man Modelle für Module in ZF generiert? Meine Logik könnte fehlerhaft sein, aber hier ist das Setup:Wie generieren Sie Modulmodelle in ZF und Doctrine?

Ich habe eine ZF-Struktur-Setup für Module. Ich habe ein Blog-Modul und ein Spielemodul. Ich wünsche, dass diese beiden Systeme unabhängig voneinander sind, aber dieselben gemeinsamen Module teilen, wie z. B. Benutzerkonten, die unter separaten Datenbanken IE Blog Database und Game Database und gehostet werden. So würde meine Struktur wie folgt aussehen:

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

Ich bin nur ein wenig verwirrt darüber, wie Sie Lehre erhalten können, die Modelle für einzelne Module zu erzeugen. Ich könnte das völlig falsch sehen, wenn irgendjemand einen Einblick gewinnen könnte, würde ich es voll und ganz schätzen, ohne es manuell zu machen. Zurück zu versuchen, mehr Forschung dafür zu tun, sehen, ob ich die Lösung finden kann.

Danke.

Antwort

1

AFAIK können Sie sie nicht auf Ihre Weise generieren :(, Entschuldigung dafür. Ich lief in das gleiche Problem einmal zuvor und ich denke, die beste Lösung ist, die Modelle aus dem Anwendungsordner zu generieren und in die Library-Ordner, so dass die Struktur würde

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 

sein, um alle Ihre Modell + das gleiche Präfix die Zeit und den Schmerz der manuellen Bearbeitung jedes erzeugten Modell seinen Namensraum zu passen retten würde.

unten meine Lehre 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

Danke dafür, Art von was ich dachte. Ich habe einige andere Ideen, bevor ich es komplett über meine eigene Gewohnheit 'Doctrine_Cli' verlasse. Aber danke, dass du das für mich bestätigt hast. Bin dankbar. –

Verwandte Themen