开发者

Do I need to hack ZendFramework1.10.8/Doctrine1.2.2 to get model generated?

I've started reading on zend framework and it's use with Doctrine and have implemented a small project to grasp the understanding.I've come to a point where i needed my model generated as in having a generate script like the one suggested in Doctrine 1.2.2 pdf manual.After few unsuccessful attempts like

Class 'sfYaml' not found in G:\php_document\zendworkspace\BookingManager\library\doctrine\Doctrine\Parser\Yml.php on line 80

i've googled and found out what people are doing about that.

To me it sounds too much the fact of having a command line script to do that work.So my question is do i really need the command line or i fail to load something is my application.ini file to get the error up there?

my testerController is like this:

class Testing_TesterController extends Zend_Controller_Action {

public function init(){
    $optionDoctrine = Zend_Registry::get("config")->toArray();
    $this->config = $optionDoctrine["doctrine"];
}


public function generateAction() {
    $this->view->drop="dropping database............";
    Doctrine_Core::dropDatabases();
    $this->view->create = "creating database........";
    Doctrine_Core::createDatabases();
    $this->view->models = "generating models....";
    //things started breadking from this line  Doctrine_Core::generateModelsFromYaml("$this->config[yaml_schema_path]","$this->config[models_path]");
//      $this->view->tables = "creating tables.......";
//          Doctrine_Core::createTablesFromModels($this->config["models_path"]);        
//      $this->view->success = "tables and model successfully generated";
//      $optionobject= Zend_Registry::get("config")->toArray();
//      $this->view->generate =$optionobject["doctrine"]["yaml_schema_path"];

}

 public function testAction(){

$dbs= Doctrine_Manager::connection()->import->listDatabases();
 $this->view->test = $dbs;
     //$this->view->test = "test";
 }
}

the generate view is like this

<h1>My Manager:: generate page</h1><br>
<div style="text-align: left"><?php echo $this->drop; ?></div>
<div style="text-align: left"><?php echo $this->create; ?></div>
<div style="text-align: left"><?php var_dump($this->models);开发者_运维技巧 ?></div>
<div style="text-align: left"><?php echo $this->tables; ?></div>

here is my bootstrap class

class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
   protected function _initDoctrine(){
    require_once 'doctrine/Doctrine.php';


      $this->getApplication()->getAutoloader()->pushAutoloader(array('Doctrine','autoload'),"Doctrine");
 //$this->getApplication()->getAutoloader()->pushAutoloader(array('Doctrine','modelsAutoload'),"Doctrine");

    $manager = Doctrine_Manager::getInstance();
 //$manager->setAttribute(Doctrine_Core::ATTR_MODEL_LOADING,Doctrine_Core::MODEL_LOADING_AGGRESSIVE);
    $manager->setAttribute(Doctrine_Core::ATTR_AUTO_ACCESSOR_OVERRIDE,true);

    $doctrineConfig = $this->getOption('doctrine');

    $conn = Doctrine_Manager::connection($doctrineConfig['dsn'],'doctrine');

    return $conn;


}

protected function _initDoctrineConfig(){

    $conf = new Zend_Config($this->getOptions(),true);
    Zend_Registry::set('config',$conf);
    return $conf;
}


}

I've also adopted the use of modules which seems to complicate my situation so what do you think is the best to go with? thanks for reading


You need to grab the sfYaml component and install it. I Thought it was int the Doctrine svn repo as an svn:external but maybe not... you can get it from the Symfony components site.

Im not sure what tutorial youre following but if you drop:

http://svn.symfony-project.com/components/yaml/branches/1.0/

into your library folder as sfYaml and add library/sfYaml to the include path you should be fine assuming youve gotten everything else set up correctly.

Also whay is your command line script using Zend_Controller stuff? Shouldnt you be using the Zend_Tool_Framework infrastructure or writing a completely custom script? Thats how I've done it in the past anyway...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜