自动加载 Zend 框架类 [英] Autoloading Zend Framework classes
问题描述
当我尝试运行下载的 zend 项目时出现此错误这是什么错误以及如何解决
Here I am getting this error whenI tried to run a downloaded zend project what is this error and how it can be solved
Warning: require_once(Zend/Application.php) [function.require-once]:
failed to open stream: No such file or directory in
C:\xampp\htdocs\sandbox\public\index.php on line 18
index.php
<?php
// Define path to application directory
defined('APPLICATION_PATH')
|| define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application'));
// Define application environment
defined('APPLICATION_ENV')
|| define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));
// Ensure library/ is on include_path
set_include_path(implode(PATH_SEPARATOR, array(
realpath(APPLICATION_PATH . '/../library'),
get_include_path(),
)));
/** Zend_Application */
require_once 'Zend/Application.php';
// Create application, bootstrap, and run
$application = new Zend_Application(
APPLICATION_ENV,
APPLICATION_PATH . '/configs/application.ini'
);
$application->bootstrap()
->run();
推荐答案
您需要在包含路径中包含 Zend 框架库".您可以在 php.ini
文件的 include_path
指令中全局执行此操作,或者更简单地在应用程序的 index.php
文件中执行此操作,例如
You need to include the Zend Framework "library" on your include path. You can either do this globally in your php.ini
file's include_path
directive or more simply in your application's index.php
file, eg
set_include_path(implode(PATH_SEPARATOR, array(
'/path/to/zend/framework/library',
realpath(APPLICATION_PATH . '/../library'),
get_include_path()
)));
如果是标准的 ZF 应用程序,index.php
中可能已经有类似的内容,只需将 ZF 路径添加到数组中即可.
If it's a standard ZF app, there will probably already be something like that in index.php
, just add the ZF path to the array.
如果您对 php.ini
文件进行了任何更改,请不要忘记重新启动 Apache.
If you do make any changes to your php.ini
file, don't forget to restart Apache.
这篇关于自动加载 Zend 框架类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!