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

发布于 2024-10-11 00:11:04 字数 4559 浏览 2 评论 0原文

我有一个在 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

I have a project running in win7 (with xampp installed - zend framework 1.10.3). But when I moved it to Ubuntu, I had a problem.
My project structure is :

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

Here is my 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();

And here is my 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

With these configurations, I have no problem on having my project run on windows (with xampp was installed).

In ubuntu, i had xampp installed following this guide:

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

According to that guidance, I've created a symlink (if i didnt wrong) to linking my /home/truong/webdev folder with /opt/lampp/htdocs folder.(with "truong" is my name ^_^)
Then i moved my project to /home/truong/webdev. After that, I run my project from browser ULR : localhost/webdev/myProject
and i had this error:

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

It looks like that the system couldn't find my library/Zend folder.

I wondered that should i set the include path for my Zend library in php.ini manually, but then I thought it wasnt neccessary, cause I had it set in index.php

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

I've searched many times on the Internet but nothing found helpful.
Please help me solving this problem...
Thanks so much.
ps: my appologize for my bad English.
quangtruong1985

Posts: 1
Joined: Thu Jan 06, 2011 4:24 pm

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

2024-10-18 00:11:04

看来您的库路径实际上并未添加到您的包含路径中。
您可能想通过 print_r(get_include_path()); 进行检查

我过去在使用 realpath 时遇到了一些问题,所以也许这就是导致您出现问题的原因。
你可以尝试

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

避免 realpath

It seems like your library path isn't actually added to your include path.
you may want to check this via print_r(get_include_path());

I had some problems with realpath in the past, so maybe this is causing your problem.
You could try

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

to avoid realpath

暮倦 2024-10-18 00:11:04

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

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

您还必须考虑以下事项:如果您的 Windows 计算机上安装了 XAMPP,则默认情况下会安装 PEAR,并且 zend 框架会附带它。

编辑:
一些语法。

It looks like you commented out the include directive in your application.ini.
It is this one: ;includePaths.library = APPLICATION_PATH "/../library". If you remove the ';' at the beginning of the line it should work out.

On your Windows machine did you add the path to the Zend Framework to the php.ini? If so that´s probably the reason why it won´t work on Linux.

You also have to consider the following: if you have an installation of XAMPP on your windows machine, PEAR is installed by default and the zend framework comes with it.

EDIT:
Some grammar.

烂柯人 2024-10-18 00:11:04

检查一下 php.ini 文件中库的包含路径是否被注释掉,

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

如果注释掉,请去掉分号并重新启动服务器。

Can you check whether the include path for the library in php.ini file is commented,

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

if commented, please remove the the semicolon and restart the server.

巷雨优美回忆 2024-10-18 00:11:04

我的 php.ini 指令是这样的

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

去除 ;在路径的末尾解决了我的问题

My php.ini directive was like this

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

removing ; at the end of path solved my problem

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文