我需要攻击ZendFramework1.10.8 / Doctrine1.2.2才能生成模型吗? [英] Do I need to hack ZendFramework1.10.8/Doctrine1.2.2 to get model generated?

查看:107
本文介绍了我需要攻击ZendFramework1.10.8 / Doctrine1.2.2才能生成模型吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经开始阅读zend框架,它与Doctrine一起使用,并且已经实现了一个小项目来掌握这个理解。我来到了一个需要我的模型生成的点,就像有一个生成脚本一样,在Doctrine 1.2.2 pdf手册中。几个不成功的尝试,如


类'sfYaml'在
中找不到G:\第80行的php_document\zendworkspace\BookingManager\library\doctrine\Doctrine\Parser\Yml.php



$ b $我已经google了,发现人们在做什么。

对我来说,听起来太多了一个命令行脚本来做这个工作的事实,所以我的问题是真的需要命令行,或者我无法加载某些东西是我的application.ini文件以获取错误?

我的testerController就是这样:

  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 =删除数据库......... ......;
Doctrine_Core :: dropDatabases();
$ this-> view-> create =创建数据库........;
Doctrine_Core :: createDatabases();
$ this-> view-> models =生成模型....;
//从这行开始面包的事情Doctrine_Core :: generateModelsFromYaml($ this-> config [yaml_schema_path],$ this-> config [models_path]);
// $ this-> view-> tables =创建表.......;
// Doctrine_Core :: createTablesFromModels($ this-> config [models_path]);
// $ this-> view-> success =表和模型成功生成;
// $ 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;
}
}

生成视图就是这样

 < h1>我的管理器::生成页面< / 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>

这是我的自举类

  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;


}

保护函数_initDoctrineConfig(){

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


}

还采用了模块的使用,这似乎使我的情况复杂化,所以你认为最好去做什么?感谢阅读

解决方案

您需要抓住 sfYaml 组件并安装它。我认为这是在Doctrine svn repo作为一个 svn:external ,但也许不是...你可以从 Symfony组件站点。



我不知道你遵循什么教程,但如果你删除: / p>

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



into您的文件夹为 sfYaml ,并将 library / sfYaml 添加到包含路径你应该很好,假设你已经把所有其他设置正确。



还有你的命令行脚本使用Zend_Controller的东西?不应该使用 Zend_Tool_Framework 基础设施或编写一个完全自定义的脚本?这是我以前在过去做的...


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

这篇关于我需要攻击ZendFramework1.10.8 / Doctrine1.2.2才能生成模型吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆