今天我们来讲一下关于php mvc模板的zend使用方法与配置实例,这是一款从zend加载 config文件到加载数据库 getinstance()方法用来获取前端控制器实例 加载smarty模板插件等简单的配置方法,实例代码如下:
- <?php
- */
-
- set_include_path('.' .
- path_separator . './libary/'.
- path_separator . './application/models/'.
- path_separator . './libary/smarty/'.
- path_separator . get_include_path());
-
-
- include "zend/loader.php";
- zend_loader::registerautoload();
-
-
-
- $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);
-
- $frontcontroller = zend_controller_front::getinstance();
-
- $frontcontroller->addmoduledirectory('./application');
-
- $frontcontroller->registerplugin(new plugin_myplugin());
-
-
-
-
-
-
-
- $viewrenderer = zend_controller_action_helperbroker::getstatichelper('viewrenderer');
- $viewrenderer->setviewsuffix('php');
-
-
- $frontcontroller->throwexceptions(true);
-
-
-
- $frontcontroller->dispatch();
- ?>
|