代码之家  ›  专栏  ›  技术社区  ›  black sensei

我需要黑客ZendFramework1.10.8/doctrine1.2.2来生成模型吗?

  •  2
  • black sensei  · 技术社区  · 15 年前

    我已经开始阅读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;
    }
    
    
    }
    

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

    1 回复  |  直到 15 年前
        1
  •  1
  •   prodigitalson    15 年前

    你需要抓住 sfYaml 组装并安装。我以为它是作为一个 svn:external 但也许不是…你可以从 Symfony components 站点。

    我不知道你在学什么教程,但是如果你放弃了:

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

    进入你的 library 文件夹为 SFYAML 并添加 library/sfYaml 对于include路径,假设您已经正确设置了所有其他内容,那么应该可以使用。

    另外,使用Zend_控制器的命令行脚本是什么?你不应该使用 Zend_Tool_Framework 基础结构还是编写完全自定义的脚本?不管怎样,我过去就是这样做的…

    推荐文章