我已經開始閱讀zend框架,它與Doctrine一起使用,並已經實現了一個小項目來理解。我來到了一個點,我需要我的模型生成,就像生成一個像1.2.2學說PDF manual.After一些不成功的嘗試像我是否需要破解ZendFramework1.10.8/Doctrine1.2.2才能生成模型?
類 'sfYaml' 不 摹發現:\ php_document \ zendworkspace \上線80 BookingManager \庫\原則\原則\分析器\ Yml.php
我搜索了一下,發現人們在做什麼。
對我來說,聽起來有太多的事實,有一個命令行腳本來做這件事。所以我的問題是,我真的需要命令行或我無法加載一些東西是我的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="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";
}
}
的產生的觀點是這樣的
<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>
這裏是我的引導類
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;
}
}
我還通過模塊的使用,其似乎使我的情況複雜化了,所以你認爲最好的做法是什麼?感謝您的閱讀
你看了[ZFDoctrine](http://github.com/beberlei/zf-doctrine)? – takeshin 2010-09-19 08:38:57
感謝您的link.was真的很有用,但又一次命令行被大量used.seems命令行的東西是得到模型生成和夾具插入的唯一方法。只是我試圖讓它從php控制器工作仍然無法正常工作。無論如何感謝閱讀。 – 2010-09-19 13:39:49
takehin我看看它。它看起來很好。我有幾個麻煩讓它運行,但似乎我不能用它與1.10.8.throwing一些錯誤有關重新聲明path.one的解決方案是註釋掉application.ini中的includePaths.library我認爲我不能沒有命令行。我要去Jon Lebensold的方式http://www.zendcasts.com/deep-integration-between-zend-and-doctrine- 1/2010/01/ – 2010-10-19 12:45:49