【www.gdgbn.com--中文酷站】

 //指明引用文件的路径
    set_include_path("." .
    PATH_SEPARATOR . "./libary/".           //指定ZEND所在目录
    PATH_SEPARATOR . "./application/models/". //指定MODEL所在目录
    PATH_SEPARATOR . "./libary/smarty/".      //指定smarty模板
    PATH_SEPARATOR . get_include_path());

    //必须手动加载Loader.php教程
    include "Zend/Loader.php";
    Zend_Loader::registerAutoload();
   
    //加载数据库教程配置文件
    //Zend/Config/Ini.php
    $config = new Zend_Config_Ini ("./application/config.ini", "general");
    $registry = Zend_Registry::getInstance();
    $registry->set("config", $config);
   
    //加载数据库
    $db = Zend_Db::factory ($config->db);
    $db->query("set names gbk");
    Zend_Db_Table::setDefaultAdapter($db);

    //getInstance()方法用来获取前端控制器实例
    $frontController = Zend_Controller_Front::getInstance();
    //指定模块目录
    $frontController->addModuleDirectory("./application");
    //加载smarty模板插件
    $frontController->registerPlugin(new plugin_MyPlugin());
   
   
    //Zend布局应用
    //$options = array("layout"=>"head","layoutpath"=>"/layouts", "contentKey" => "CONTENT");
    //$layout = new Zend_Layout($options);


    //设置模板后缀名
    $viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper("viewRenderer");
    $viewRenderer->setViewSuffix("php");

    //抛出异常
    $frontController->throwExceptions(true);

   
    //开始运行程序
    $frontController->dispatch();

本文来源:http://www.gdgbn.com/kuzhan/23772/