Zend Framework的新功能。我一直在閱讀,發現無論在application.ini中提到什麼都被初始化。索引和application.ini混淆和一些簡單的問題
1 - 我的問題是,如果我提到包括圖書館比我爲什麼需要使用INI路徑一樣
// Include path
set_include_path(
BASE_PATH . '/library'
);
2索引文件又包含路徑 - 中的application.ini應我寫了像APPLICATION_PATH「/../library」或APPLICATION_PATH「/ library」的includePaths.library。請記住我的索引APPLICATION_PATH變量?
3 -爲什麼要在BootStarp文件中使用_initView()。是什麼樣
$viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper(
'ViewRenderer'
);
$viewRenderer->setView($view);
的application.ini使用該代碼的提到
;Include path
includePaths.library = APPLICATION_PATH "/../library"
引導
<?php
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
protected function _initView()
{
// Initialize view
$view = new Zend_View();
$view->doctype('XHTML1_STRICT');
$view->headTitle('My Project');
$view->env = APPLICATION_ENV;
// Add it to the ViewRenderer
$viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper(
'ViewRenderer'
);
$viewRenderer->setView($view);
// Return it, so that it can be stored by the bootstrap
return $view;
}
}
指數
<?php
define('BASE_PATH', realpath(dirname(__FILE__) . '/../'));
define('APPLICATION_PATH', BASE_PATH . '/application');
// Include path
set_include_path(
BASE_PATH . '/library'
);
// Define application environment
defined('APPLICATION_ENV')
|| define('APPLICATION_ENV',
(getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV')
: 'production'));
// Zend_Application
require_once 'Zend/Application.php';
$application = new Zend_Application(
APPLICATION_ENV,
APPLICATION_PATH . '/configs/application.ini'
);
$application->bootstrap();
$application->run();
你喜歡INI圖書館和初始化。對? – Pirzada
爲了設置包含路徑,我更喜歡在index.php中使用代碼。所有其他配置都在應用程序配置文件中 – Phil