2
votes

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

1
Have you looked at ZFDoctrine?takeshin
Thanks for the link.was really useful but there again command line was heavily used.seems command line stuffs are the only way to get model generated and fixtures inserted.Sadly my attempt to get it work from php controller still isn't working.Thanks for reading anyway.black sensei
takeshin i had a look at it.It looks fine.i had couple of troubles getting it running but it seems that i cannot use it with 1.10.8.throwing some errors about redeclaring the path.one of the solution was to comment out includePaths.library in application.ini.I think i can't do without the command line.I'm going the Jon Lebensold way zendcasts.com/deep-integration-between-zend-and-doctrine-1-2/…black sensei

1 Answers

1
votes

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...