警告:在/var/www/html/myapp/public/index.php中,无法打开流Zend/Application.php:没有这样的文件或目录。

3

我的索引文件是这个

<?php
ini_set( "short_open_tag", 1 );
ini_set( "display_errors", 1 );
// 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'
);

// Let 'er rip
$application->bootstrap()->run();

当我运行它时

警告:在/var/www/Giftercity_backup/index.php的第18行,无法打开Zend/Application.php文件流:没有此类文件或目录 致命错误:在/var/www/Giftercity_backup/index.php的第18行,需要打开“Zend/Application.php”(包含路径=':.:/usr/share/php:/usr/share/pear')失败


经常会遇到这个错误,为了快速排除故障,请按照以下步骤操作:https://dev59.com/LVoV5IYBdhLWcg3wL8Ww#36577021 - Vic Seedoubleyew
3个回答

6

对于Ubuntu系统。
如果你安装了ZendFramework包,例如sudo apt-get install zend-framework
它会将Zend库文件放在/usr/share/php/libzend-framework-php/Zend/文件夹中
你只需要复制并粘贴那个Zend/文件夹到/user/share/php/文件夹中
在终端中运行以下命令即可。

cd /usr/share/php
sudo cp -R libzend-framework-php/Zend/ Zend

3
我会创建符号链接,但你的回答本质上就是我所做的。 - Angel.King.47
@Angel.King.47,是的,你也可以这样做。 - chanchal
现在有一个针对这个常见错误的故障排除清单,请查看此链接:https://dev59.com/LVoV5IYBdhLWcg3wL8Ww#36577021 - Vic Seedoubleyew

1
把你的索引文件放在“public”目录中。
或者,如果你想或不能包含来自父目录的文件,你需要更改这一行:
set_include_path(implode(PATH_SEPARATOR, array(
  realpath(APPLICATION_PATH . '/../library'),
  get_include_path(),
)));

set_include_path(implode(PATH_SEPARATOR, array(
  realpath(APPLICATION_PATH . '/library'), // Here we have change
  get_include_path(),
)));

当然,我假设您已经将Zend文件放入library / Zend中。
您还需要记住将带有“deny from all”的.htaccess文件放入应用程序,库和任何其他不希望用户访问的目录中。
顺便说一句。 这种包含库的方法相当陈旧,不建议使用。

0
如果您的index.php文件位于/var/www/Giftercity_backup/index.php(根据错误输出),那么根据您的代码,library位置应该在/var/www/library,而application应该在/var/www/application,这听起来是错误的。 index.php应该位于公共文件夹中,例如/var/www/Giftercity_backup/public/var/www/Giftercity_backup/htdocs或类似的文件夹,您的VirtualHost DocumentRoot应该指向该文件夹。
此外,您的set_include_path没有注册library(include_path=':.:/usr/share/php:/usr/share/pear')。

现在有一个针对这个常见错误的故障排除清单,链接在这里:https://dev59.com/LVoV5IYBdhLWcg3wL8Ww#36577021 - Vic Seedoubleyew

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接