无法加载 Zend/Loader.php.试图找出原因? [英] Failed to load Zend/Loader.php. Trying to work out why?

查看:32
本文介绍了无法加载 Zend/Loader.php.试图找出原因?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我继承了一个客户站点,该站点每 3 或 4 天崩溃一次.它是使用我不了解的 zend 框架构建的.

以下代码:

导致以下错误:

<前>[Tue Sep 02 12:58:45 2008] [error] [client 78.***.***.32] PHP 警告:require_once(Zend/Loader.php) [function.require-once]:无法打开流:第 6 行的/srv/www/vhosts/example.co.uk/httpdocs/bootstrap.php 中没有这样的文件或目录[2008 年 9 月 2 日星期二 12:58:45] [错误] [客户端 78.***.***.32] PHP 致命错误:require_once() [function.require]:无法打开所需的Zend/Loader.php"' (include_path='.:.:/usr/share/php5:/usr/share/php5/PEAR') 在/srv/www/vhosts/example.co.uk/httpdocs/bootstrap.php 第 6 行

我什至不知道从哪里开始尝试解决这个问题.我的 PHP 知识水平中等,但就像我说的,我没有使用 Zend 的经验.此外,联系原始开发人员也不是一种选择.

有趣的是,即使每次点击网站页面时都会运行代码,但错误只是偶尔发生.

我相信这一定与 include_path 有关,但我不确定.

解决方案

首先,我认为您的包含路径应​​该有一个尾部斜杠.这是我的一个例子:

 set_include_path('../library/ZendFramework-1.5.2/library/:../application/classes/:../application/classes/excpetions/:../application/forms/');

您的引导文件将包含在另一个文件中(可能是 index.php 文件).这意味着如果你的包含路径是相对的(就像我的一样)而不是绝对的,那么如果包含 bootstrap.php 的文件发生变化,那么查找 Loader.php 的路径也会发生变化.

例如,我的 Zend 应用程序中有两个 index.php 文件,一个用于前端,另一个用于管理区域.这些索引文件每个都需要有自己的具有不同相对路径的 bootstrap.php,因为它们包含在不同的索引文件中,这意味着它们必须相对于原始请求的索引文件,而不是它们在其中定义的引导文件.

这可以解释为什么您的问题是间歇性的,可能有另一个文件,其中包含仅偶尔使用的引导程序.我会在所有站点文件中搜索bootstrap.php",并查看包含/需要此文件的所有位置.

I have inherited a client site which crashes every 3 or 4 days. It is built using the zend-framework with which I have no knowledge.

The following code:

<?php
    // Make sure classes are in the include path.
   ini_set('include_path', ini_get('include_path') . PATH_SEPARATOR . 'lib' . PATH_SEPARATOR . 'app' . DIRECTORY_SEPARATOR . 'classes');

    // Use autoload so include or require statements are not needed.
    require_once 'Zend/Loader.php';
    Zend_Loader::registerAutoload();

    // Run the application.
    App_Main::run('production');

Is causing the following error:

[Tue Sep 02 12:58:45 2008] [error] [client 78.***.***.32] PHP Warning: require_once(Zend/Loader.php) [function.require-once]: failed to open stream: No such file or directory in /srv/www/vhosts/example.co.uk/httpdocs/bootstrap.php on line 6 
[Tue Sep 02 12:58:45 2008] [error] [client 78.***.***.32] PHP Fatal error: require_once() [function.require]: Failed opening required 'Zend/Loader.php' (include_path='.:.:/usr/share/php5:/usr/share/php5/PEAR') in /srv/www/vhosts/example.co.uk/httpdocs/bootstrap.php on line 6 

I don't even know where to begin trying to fix this. My level of knowledge of PHP is intermediate but like I said, I have no experience with Zend. Also, contacting the original developer is not an option.

The interesting thing is that even though the code is run every time a page of the site is hit the error is only happening every now and then.

I believe it must be something to do with the include_path but I am not sure.

解决方案

for a start I think your include path should maybe have a trailing slash. Here is an example of mine :

    set_include_path('../library/ZendFramework-1.5.2/library/:../application/classes/:../application/classes/excpetions/:../application/forms/'); 

You bootstrap file will be included by another file (probably an index.php file). This means that if your include path is relative (as mine is) instead of absolute, then the path at which Loader.php is looked for changes if the file including bootstrap.php changes.

For example, I have two index.php files in my Zend app, one for the front end, and one for the admin area. These index files each need there own bootstrap.php with different relative paths in because they are included by different index files, which means they have to be relative to the original requested index file, not the bootstrap file they are defined within.

This could explain why your problem is intermittent, there could be another file including the bootstrap somewhere that is only used occasionally. I'd search through all the sites files for 'bootstrap.php' and see all the places which are including / requiring this file.

这篇关于无法加载 Zend/Loader.php.试图找出原因?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆