1
在Zend框架中,如何在我的bootstrap.php文件中使用setHelperPath方法使框架可以訪問「My_View_Helper_Test」(假設Helper絕對路徑是常量'MY_PATH')?Zend setHelperPath in Bootstrap
我的index.php
//identify the location of th application dir in respect to
//the botstrap file's location, and configure PHP's include_path to
//include the library directory's location
define('APPLICATION_PATH',realpath(dirname(__FILE__).'/../application'));
set_include_path(APPLICATION_PATH.'/../library'.PATH_SEPARATOR.get_include_path());
//give the zend framework the ability to load classes on demand,
//as you request them,rather than having to deal with require() statements.
require_once 'Zend/Loader/Autoloader.php';
Zend_Loader_Autoloader::getInstance();
//retrieve the BOOTSTRAP file
try
{
require'../application/bootstrap.php';
}
catch(Exception $exception)
{
printf('Could not locate bootstrap.php');
exit(1);
}
//start using the front controller in order to route all requests
Zend_Controller_Front::getInstance()->dispatch();
我的bootstrap.php
//configure the site environment status
defined('APPLICATION_ENVIRONMENT')or define('APPLICATION_ENVIRONMENT','development');
//invoke the front controller
$frontController=Zend_Controller_Front::getInstance();
//identify the location of the controller directory
$frontController->setControllerDirectory(APPLICATION_PATH.'/controllers');
//create the env parameter so you can later access the environment
//status within the application
$frontController->setParam('env',APPLICATION_ENVIRONMENT);
//clean up all allocated script resources
unset($frontController);
感謝
盧卡
感謝,如果我想使用舊的程序辦法(不想使用自舉類是什麼?既不zend_application) – luca 2011-05-12 07:29:32
我還沒有測試過它,但我想你可以在上面的'_initView()'方法中使用相同的代碼,當然除了'return $ view'這行。 – 2011-05-12 13:18:38