php zend configuration, database plus, template engine settings

Source: Internet
Author: User
Keywords Network programming PHP tutorial
Tags application configuration configuration examples control directory examples file network

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 ();
?>

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.