`
fireDragonpzy
  • 浏览: 472420 次
  • 性别: Icon_minigender_1
  • 来自: 济南
社区版块
存档分类
最新评论

php之ZendFramewor篇(二)zf+samrty index.php 配置

阅读更多
	<?php

error_reporting (E_ALL & ~E_DEPRECATED & ~E_NOTICE);
 
date_default_timezone_set ( 'Asia/Shanghai' );

define('ROOT_PATH',($ROOT_PATH =dirname(__FILE__))? $ROOT_PATH : '..');

defined ( 'APPLICATION_PATH' ) || define ( 'APPLICATION_PATH', realpath ( dirname ( __FILE__ ) . '/../application' ) );

defined ( 'APPLICATION_ENV' ) || define ( 'APPLICATION_ENV', (getenv ( 'APPLICATION_ENV' ) ? getenv ( 'APPLICATION_ENV' ) : 'production') );

set_include_path ( implode ( PATH_SEPARATOR, array (realpath ( APPLICATION_PATH . '/../library' ), get_include_path () ) ) );
set_include_path ( '.' . PATH_SEPARATOR . '../application/controllers/' . '../application/models/' . '../application/dao/' . PATH_SEPARATOR . get_include_path () );

require_once "Zend/Loader/Autoloader.php";
Zend_Loader_Autoloader::getInstance ()->setFallbackAutoloader ( true );
$registry = Zend_Registry::getInstance ();

$config = new Zend_Config_Ini ( '../application/configs/application.ini', null, true );
Zend_Registry::set ( 'config', $config );
$dbAdapter = Zend_Db::factory ( $config->database->db->adapter, $config->database->db->config->toArray () );
$dbAdapter->query ( 'SET names utf8' );
Zend_Db_Table::setDefaultAdapter ( $dbAdapter );
Zend_Registry::set ( 'db', $dbAdapter );

require_once 'Zend/Log.php';
require_once 'Zend/Log/Writer/Stream.php';
$logger = new Zend_Log ( new Zend_Log_Writer_Stream ( '.' . $config->log->logger->path, 'a+' ) );
Zend_Registry::set ( 'logger', $logger );

$view = new Zend_View ();
$view->setScriptPath ( './templates/' );
$view->setHelperPath('./templates/helpers', 'Zend_View_Helper');
$registry ['view'] = $view;

include_once ("../library/Smarty/Smarty.class.php");
$smarty = new Smarty ();
$smarty->caching = false;
$smarty->template_dir = "./templates/";
$smarty->compile_dir = "./data/smarty/";
$smarty->cache_dir = "./data/smarty/cache_c/";
//$smarty->left_delimiter = "<{";
//$smarty->right_delimiter = "}>";
$registry = Zend_Registry::getInstance ();
$registry->set ( 'smarty', $smarty );

$front = Zend_Controller_Front::getInstance ();
$front->setBaseUrl ( '/' );
$front->setParam ( 'useDefaultControllerAlways', true );
$front->setParam ( 'noViewRenderer', true );
$front->setControllerDirectory ( '../application/controllers' );
$front->throwExceptions ( true );
Zend_Session::start();
require_once 'Zend/Application.php';
$application = new Zend_Application ( APPLICATION_ENV, APPLICATION_PATH . '/configs/application.ini' );
$application->bootstrap ()->run ();

?>
分享到:
评论

相关推荐

    samrty模板

    - `templates/`:存放模板文件的目录,如`index.tpl`,`about.tpl`等。 - `templates_c/`:Smarty编译后的PHP文件存储位置,这是Smarty将模板转换成PHP的结果。 - `configs/`:配置文件目录,包含如`config.php`,...

    [php]smarty实例及ajax的应用

    2. **配置和实例化**:在`index.php`中,你需要先配置Smarty,包括设置模板目录、缓存目录等,然后实例化一个Smarty对象。例如: ```php $smarty = new Smarty(); $smarty-&gt;template_dir = 'path/to/templates'; ...

    smarty-3.1.29

    6. **配置选项**:Smarty允许开发者根据项目需求调整其行为,例如设置默认的模板目录、缓存目录,或者定义自定义的函数和函数插件。 7. **面向对象编程支持**:Smarty支持面向对象编程,可以方便地与现代PHP框架...

    samrty入门学习简介

    #### 二、Smarty 的优势 **2.1 易于学习与使用** Smarty 提供了一套简洁明了的语法结构,这使得即使是初学者也能快速上手。其语法类似于 HTML,因此前端开发者也可以轻松理解和修改模板文件。 **2.2 强大的功能集...

    samrty心得

    #### 二、Smarty缓存变量 在Smarty中,可以通过各种方法来缓存变量,从而提高页面渲染的速度。例如,通过`assignvar`标签可以定义变量并赋值: ```smarty $content[li].id|cvts:'ctrip_content':'id':'desc'}&gt;$...

    新生代企业网站管理系统 v1.0

    整套系统的设计构造,完全考虑大中小企业类网站的功能要求,网站的后台功能强大,管理简捷,支持模板机制,配置中英文双语言版.能够快速的建立您的企业网站。&lt;/font&gt;&lt;/p&gt; 系统特性: 采用流行的php+mysql+smarty设计...

    新生代企业网站管理系统v2.0GBK build091007

    整套系统的设计构造,完全考虑大中小企业类网站的功能要求,网站的后台功能强大,管理简捷,支持模板机制,配置中英文双语言版.能够快速的建立您的企业网站。&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;fontface&gt;系统特性: 采用流行的...

    大师兄smart教程

    ### 二、安装与配置Smarty #### 安装过程: 1. **下载安装包**:可以从官方网站(http://samrty.php.net/)下载最新版本的Smarty安装包。 2. **解压文件**:解压下载的安装包到一个合适的目录,通常会解压到项目的`...

    2014年辛星PHP教程秋季版之Smarty模板.pdf )

    在本部分中,辛星主要讲述了PHP模板技术的概念、Smarty模板引擎的使用方法以及模板技术的重要性,并且分享了作者对个人学习和教育编程的态度和承诺。 首先,辛星指出模板技术并不是PHP独有的,它是Web开发中常见的...

    新生代企业网站管理系统 2.0.rar

    新生代企业网站管理系统是一款基于php mysql samrty的免费开源建站系统。整套系统的设计构造,完全考虑大中小企业类网站的功能要求,网站的后台功能强大,管理简捷,支持模板机制,配置中英文双语言版.能够快速的建立...

    SMARTY模版范例

    - **SMARTY实例化**:在PHP代码中,我们需要创建一个Smarty对象实例,然后设置配置参数,如模板目录、缓存目录等。 - **数据绑定**:将PHP变量传递给Smarty实例,这些变量可以在模板文件中使用。 - **编译模板**...

    深入解析php模板技术原理【一】

    #### 二、PHP标签模板技术 最开始的解决方案是使用PHP标签本身作为模板技术的基础。这种方式通过简单的PHP标签实现了数据的获取和展示的分离。 **1. 数据获取**:比如`getnews.php`负责从数据库中读取新闻数据并...

Global site tag (gtag.js) - Google Analytics