将项目从win7移动到Ubuntu时无法加载Zend / Application.php

时间:2011-01-07 08:14:42

标签: zend-framework frameworks windows-7 ubuntu

我有一个在win7中运行的项目(安装了xampp - zend framework 1.10.3)。但是当我把它移到Ubuntu时,我遇到了一个问题。 我的项目结构是:

Myproject
    application
    library
        Zend
    include
        application.ini
    etc...
    index.php

这是我的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'));

define('APP_ROOT', realpath(dirname(dirname(__FILE__))));

// Ensure library/ is on include_path
set_include_path(implode(PATH_SEPARATOR, array(
    realpath(APPLICATION_PATH . '/../library'),
    get_include_path(),
)));

require_once 'include/constant.inc.php';
require_once('include/class.phpmailer.php');

// set constant in Zend_Registry
//require_once 'Zend/Registry.php';
//Zend_Registry::set('const', $cfg);

/** Zend_Application */
require_once 'Zend/Application.php';

// Create application, bootstrap, and run
$application = new Zend_Application(
    APPLICATION_ENV,
    APPLICATION_PATH . '/../include/application.ini'
);
$application->bootstrap()
            ->run();

这是我的include / application.ini:

[production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1
phpSettings.date.timezone = "Europe/London"
;includePaths.library = APPLICATION_PATH "/../library"
bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
bootstrap.class = "Bootstrap"
appnamespace = ""

;resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers"
;resources.frontController.params.displayExceptions = 0
resources.frontController.moduleDirectory = APPLICATION_PATH "/modules"
resources.modules = ""

autoloaderNamespaces.Zendex = "Zendex_"


resources.db.adapter = PDO_MYSQL
resources.db.params.host = localhost
resources.db.params.username = root
resources.db.params.password = 
resources.db.params.dbname = qtcms
resources.db.params.charset = "utf8"


resources.layout.layoutPath = APPLICATION_PATH "/layouts/scripts/"
resources.view[] =
;resources.layout.layout = "layout"
admin.resources.layout.layout = "admin"
resources.view.doctype = "XHTML1_STRICT"
resources.view.helperPath    = APPLICATION_PATH "/helpers/views/"
resources.view.helperPathPrefix = "Zend_View_Helper_"
;resources.view.params.default.basePath                            = APPLICATION_PATH "/layouts/default/"
;resources.view.params.default.layout                              = "layout"
;resources.view.params.default.layoutPath                          = APPLICATION_PATH "/layouts/default/default/"

;resources.view.params.admin.basePath                            = APPLICATION_PATH "/layouts/admin/"
;resources.view.params.admin.layout                              = "layout"
;resources.view.params.admin.layoutPath                          = APPLICATION_PATH "/layouts/admin/default/"



[staging : production]

[testing : production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1

[development : production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1
resources.frontController.params.displayExceptions = 1

通过这些配置,我可以在Windows上运行我的项目(安装了xampp)。

在ubuntu中,我按照本指南安装了xampp:

http://humanlanguage.wordpress.com/2006/12/03/install-xampp-on-ubuntu/

根据该指导,我创建了一个符号链接(如果我没错),将 / home / truong / webdev 文件夹与 / opt / lampp / htdocs 文件夹。(“truong”是我的名字^ _ ^) 然后我将我的项目移动到/ home / truong / webdev。之后,我从浏览器ULR运行我的项目: localhost / webdev / myProject 我有这个错误:

Warning: require_once(Zend/Application.php) [function.require-once]: failed to open stream: No such file or directory in /home/truong/webdev/qtcms/index.php on line 28

Fatal error: require_once() [function.require]: Failed opening required 'Zend/Application.php' (include_path=':.:/opt/lampp/lib/php') in /home/truong/webdev/qtcms/index.php on line 28

看起来系统找不到我的库/ Zend文件夹。

我想知道我应该手动在php.ini中为我的Zend库设置包含路径,但后来我认为它不是必要的,因为我把它设置在index.php中

// Ensure library/ is on include_path
set_include_path(implode(PATH_SEPARATOR, array(
            realpath(APPLICATION_PATH . '/../library'),
            get_include_path(),
)));

我在互联网上搜索了很多次,但没有找到任何帮助。 请帮我解决这个问题...... 非常感谢。 ps:我为我糟糕的英语道歉。 quangtruong1985

帖子:1 加入:2011年1月6日星期四下午4:24

4 个答案:

答案 0 :(得分:1)

您的库路径似乎实际上未添加到您的包含路径中。 您可以通过print_r(get_include_path());

进行检查

过去我遇到过一些关于realpath的问题,所以这可能会导致你的问题。 你可以试试

set_include_path(implode(PATH_SEPERATOR, array(
    dirname(__FILE__) . '/library',
    get_include_path(),
)));

避免使用realpath

答案 1 :(得分:0)

看起来您在application.ini中注释掉了include指令。 就是这个:;includePaths.library = APPLICATION_PATH "/../library"。如果你删除';'它应该在行的开头处解决。

在您的Windows机器上,您是否已将Zend Framework的路径添加到php.ini中?如果是这样,那可能是它无法在Linux上运行的原因。

您还必须考虑以下事项:如果您在Windows机器上安装了XAMPP,默认情况下会安装PEAR,并且随附了zend框架。

编辑: 一些语法。

答案 2 :(得分:0)

您可以检查php.ini文件中库的包含路径是否已注释,

; include_path =“.; c:\ php \ includes; d:.. \ zendframework \ library”

如果已注释,请删除分号并重新启动服务器。

答案 3 :(得分:0)

我的php.ini指令就像这样

include_path =“.; C:\ xampp \ php \ PEAR; C:\ zend \ zendframework1116; C:\ zend \ zendframework1116 \ library;”

去除;在路径的尽头解决了我的问题