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

WBOY
풀어 주다: 2016-06-13 13:20:17
원래의
789명이 탐색했습니다.

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 = "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 ();

?>
로그인 후 복사
관련 라벨:
원천:php.cn
본 웹사이트의 성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.
인기 튜토리얼
더>
최신 다운로드
더>
웹 효과
웹사이트 소스 코드
웹사이트 자료
프론트엔드 템플릿