views:

102

answers:

1

Hello Experts!!
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  A: 

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

prodigitalson
thanks for the fast response.In fact there is doctrine/vendor/sfYaml which contains the class and that's what got me off because to me doctrine is supposed to find it since it's the same thing that i use in my other doctrine toturial project which so far is working without me trying to fix anything.thanks
black sensei
And youve set up the Zend autoloading to work with Doctrine correct? If i recall you need to push an autloader onto the stack in addition to registering the Doctrine namespace...
prodigitalson
i think so.I've edited the post by putting what i use as bootstrap class.and i'm not using a command line. i'm asking if it possible not to use it to generate model classes from controller
black sensei
Well im sure its possible... if i recall there is a Symfony plugin that does this for when you dont have ssh access for some godforsaken reason. However unless you have to use a browser interface id urge you to stick with the CLI. Anyway the reason youre getting the error now is because it cant seem to autoload sfYaml. Not sure why i dont remeber having that problem, but it shouldnt be unique to trying to do this via a browser interface. Try adding `doctrine/vendor/sfYaml` to the include path, and then explicitly requiring it in your bootstrap or controller `init`.
prodigitalson
i dont have a "central" doctrine installation, i include them in the library of each project because there might be situation where i want to work with the version 1.2 and try out the version 2. so in that case, adding to php include path will mean having a central installation unless there is another way to achieving the include path that you are suggesting
black sensei
I wasnt talkin abotu a central installation i was talking about using `set_include_path` to add the installtion for the project durin the bootstraping process for example: `set_include_path(realpath(APP_DIR . '/../library/Doctrine/vendor/sfYaml') . PATH_SEPARATOR . get_include_path());`
prodigitalson