我已经开始阅读Zend框架,它与条令一起使用,并实施了一个小项目来掌握理解。我已经到了一个需要生成我的模型的阶段,就像生成条令1.2.2 pdf手册中建议的脚本一样。在几次失败的尝试之后喜欢
在中找不到类“sfyaml”
G:\php\u document\zendworkspace\bookingmanager\library\district\district\parser\yml.php
在线80
我在谷歌上搜索了一下,发现人们在做什么。
对我来说,有一个命令行脚本来完成这项工作听起来太过了。所以我的问题是,我真的需要命令行吗?还是我加载失败了?我的application.ini文件就是为了把错误显示出来?
我的测试控制器是这样的:
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;
}
}
我还采用了模块的使用,这似乎使我的情况复杂化,所以您认为最好使用什么?谢谢你的阅读