啓用Zend擴展爲您上面提到的是不相關的,包括你想要做的ZF類。下載ZF並將其上傳到public_html
文件夾中的任何位置,如果該文件夾尚未在某個位置提供。使用set_include_path()
並去!下面的示例代碼:
<?php
// Define relative path to ZendFramework in public_html
define('ZF_PATH', '/../../../lib/php/zendframework');
// Define path to application directory
defined('APPLICATION_PATH') || define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application'));
// Define real path to ZendFramework if it's not yet included in include_path
if(!strpos(get_include_path(), 'zendframework'))
define('ZF_REAL_PATH', realpath(APPLICATION_PATH . ZF_PATH));
else define('ZF_REAL_PATH', '');
// Updating include_path
set_include_path(implode(PATH_SEPARATOR, array(ZF_REAL_PATH, get_include_path(),)));
// Done! the rest of the code might be unnecessary in your case.
require 'Zend/Application.php';
// Create application, bootstrap, and run
$application = new Zend_Application(APPLICATION_ENV, APPLICATION_PATH . '/configs/application.ini');
$application->bootstrap()->run();
這似乎是增加一個目錄,包括路徑的情況有點複雜,但它是最常見的方式ZF應用程序使用,我想。