我已经开始阅读zend框架并且它与Doctrine一起使用并且已经实现了一个小项目来掌握理解。我已经到了一个点,我需要生成模型,就像生成一个类似于建议的生成脚本在Doctrine 1.2.2 pdf手册中。经过几次不成功的尝试,如
类'sfYaml'未找到 G:\ php_document \ zendworkspace \ BookingManager \库\原则\原则\分析器\ Yml.php 在第80行
我用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="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;
}
}
我也采用了模块的使用,这似乎使我的情况变得复杂,那么您认为最适合的是什么?感谢您的阅读
答案 0 :(得分:1)
您需要抓取sfYaml
组件并进行安装。我认为它是作为svn:external
的Doctrine svn repo,但也许不是......你可以从Symfony components站点获取它。
我不确定您关注的是什么教程,但如果您放弃:
http://svn.symfony-project.com/components/yaml/branches/1.0/
将library
文件夹添加到sfYaml
文件夹并将library/sfYaml
添加到包含路径中,假设您已正确设置其他所有内容,那么就应该没问题。
使用Zend_Controller的东西还有你的命令行脚本吗?你不应该使用Zend_Tool_Framework
基础设施或编写完全自定义的脚本吗?多数民众赞成在过去我是如何做到的......