Today we talk about the use of php mvc template zend and configuration examples, which is a load from the zend file to load the database getinstance () method used to obtain the front-end control Instance load smarty template plug-ins and other simple configuration method.
* /
// specify the path to the reference file
set_include_path ('.'.
path_separator. './libary/'. / / specify the directory where zend
path_separator. './application/models/'. // Specify the directory where the model is located
path_separator. './libary/smarty/'.
path_separator. get_include_path ());
// You must manually load loader.php
include "zend / loader.php";
zend_loader :: registerautoload ();
// Load the database configuration file
//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);
The // getinstance () method is used to get the front controller instance
$ frontcontroller = zend_controller_front :: getinstance ();
// specify the module directory
$ frontcontroller-> addmoduledirectory ('./application');
// Load smarty template plugin
$ frontcontroller-> registerplugin (new plugin_myplugin ());
// zend layout application
// $ options = array ("layout" => "head", "layoutpath" => "/ layouts", 'contentkey' => 'content');
// $ layout = new zend_layout ($ options);
// set the template suffix name
$ viewrenderer = zend_controller_action_helperbroker :: getstatichelper ('viewrenderer');
$ viewrenderer-> setviewsuffix ('php');
//Throw an exception
$ frontcontroller-> throwexceptions (true);
// start running the program
$ frontcontroller-> dispatch ();
?>