Ubuntu+Netbeans-Zend框架由于Include路径而出现致命错误


Ubuntu + Netbeans - Zend framework fatal error due to Include path

在新安装的Zend框架中,我的'include'路径出现问题。我正在运行Ubuntu并使用Netbeans。我通过终端安装了Zend,并将适当的文件复制到我的新项目中。

我目前在尝试访问localhost/demoZend/public时收到了这个消息

Warning: require_once(Zend/Application.php): failed to open stream: No such file or directory in /home/mastered/public_html/demoZend/public/index.php on line 18
Fatal error: require_once(): Failed opening required 'Zend/Application.php' (include_path='/home/mastered/public_html/demoZend/library:.:/opt/lampp/lib/php') in /home/mastered/public_html/demoZend/public/index.php on line 18

我已经将带有框架的"Zend"文件夹复制到我的项目/库文件夹中,因此文件夹结构为/demoZend/library/Zend/

我还根据教程的建议更改了php.ini中的include路径。然而,这正是我感到困惑的地方。

路径为:

include_path = ".:/usr/share/php:/usr/share/php/libzend-framework-php/"

在我的apache2/php.ini以及我的/etc/php5/cli/php.ini文件中。

我的项目中的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(); 

我没有改变,因为文件路径看起来还可以。我还应该指出,我的web文档存储在"~/public_html"目录中,我已经检查了"demoZend/library"文件夹上的权限,它们有所有限制关闭

听起来你在学习Zend Framework 1的教程,但你已经下载了Zend Framework 2。ZF2中没有Zend/Application.php,所以PHP找不到该文件。

您可以返回ZF下载页面,获取ZF1的最新版本(目前为1.12.3),也可以找到ZF2教程,转而学习ZF2。如果你刚开始使用ZF,我会选择后一种选择。