PHP,Zend,require“once:”;“无法打开流”;及;未能打开所需文件[…]”;

PHP,Zend,require“once:”;“无法打开流”;及;未能打开所需文件[…]”;,php,zend-framework,filesystems,include,Php,Zend Framework,Filesystems,Include,我快发疯了!我已经搜索了两个小时了 简言之,事情进展顺利,然后我进行了一些班级重组,现在我得到了: Warning: require_once(Zend/Mail/Transport/Sendmail.php) [function.require-once]: failed to open stream: No such file or directory in /nfs/c09/h02/mnt/136160/domains/xyz.com/html/sandbox/Zend/Mail.

我快发疯了!我已经搜索了两个小时了

简言之,事情进展顺利,然后我进行了一些班级重组,现在我得到了:

    Warning: require_once(Zend/Mail/Transport/Sendmail.php) [function.require-once]: failed to open stream: No such file or directory in /nfs/c09/h02/mnt/136160/domains/xyz.com/html/sandbox/Zend/Mail.php on line 1175

    Fatal error: require_once() [function.require]: Failed opening required 'Zend/Mail/Transport/Sendmail.php' (include_path='.:/usr/local/php-5.3.13/share/pear') in /nfs/c09/h02/mnt/136160/domains/xyz.com/html/sandbox/Zend/Mail.php on line 1175
我没有提到我的文件是如何组织的:

    sandbox/index.php
    sandbox/settings.php
    sandbox/lib/class1.php
    sandbox/lib/class2.php
    sandbox/lib/class3.php
    sandbox/Zend/...
我只更改了一些类名和它们的层次结构

index.php

<?php
    require_once 'lib/class1.php';
    $application = new class1();
    $application->run();
?>
<?php

    require_once 'Zend/Loader.php';
    Zend_Loader::loadClass('Zend_Log');
    Zend_Loader::loadClass('Zend_Log_Formatter_Simple');
    Zend_Loader::loadClass('Zend_Log_Writer_Mail');
    Zend_Loader::loadClass('Zend_Log_Writer_Stream');
    Zend_Loader::loadClass('Zend_Mail');

    // class definition ...
?>
(注意只有在第一次尝试发送电子邮件时才调用
require
。)

  • 新的“流”或包含顺序是否可能导致此问题?(因为路径看起来不错。如果路径不好,它会死在Loader.php,不是吗?)

  • 在导致更“致命”的问题之前,某种循环依赖是否会导致此问题

  • 类名是否可能与已存在的内容冲突?以前我有一些相当神秘的类名,比如MalaFwk_Application_Receiver。现在,名称更加通用,例如capapplication、CComponent、CDatabase、clocker等

  • 我尝试过其他SO线程中建议的各种方法,但都没有效果,但我愿意尝试任何人建议的方法。如果这不是一个特别有建设性的问题,我提前表示歉意,但我已经没有想法了,而且有太多(微不足道但广泛的)更改需要逐一恢复和重新应用这些更改。任何帮助都将不胜感激。(我将在美国东部时间大约8:45回来。)

    更新:

    如果我将以下行添加到index.php,即“手动”在其他任何事情发生之前需要该文件,那么事情会再次发生

        require_once 'Zend/Mail/Transport/Sendmail.php';
    

    因此,似乎出于某种原因,当代码到达
    send()
    时,它找不到库。什么可能导致这种情况?

    请将其添加到索引中:

    set_include_path(implode(PATH_SEPARATOR, array(          
        realpath('../library'), // Make sure this is the correct path to your library folder
        get_include_path(),
    )));
    

    请将此添加到您的索引中:

    set_include_path(implode(PATH_SEPARATOR, array(          
        realpath('../library'), // Make sure this is the correct path to your library folder
        get_include_path(),
    )));
    

    听起来你的include\u路径好像被覆盖了。如果您有application.ini文件,请检查其中的路径。我还建议您使用autoloader,而不是手动加载类,这只会让您的工作更轻松。听起来您的include_路径似乎被覆盖了。如果您有application.ini文件,请检查其中的路径。我还建议你使用自动加载器,而不是手动加载类,这只会让生活更轻松。你是一个向导吗?!就这样
    realpath('.')
    在我的例子中,因为我的
    Zend
    目录与
    require
    ing文件共享同一个目录。非常感谢你!作为旁注:我已经基于其他线程尝试了
    set\u include\u path()
    ,但关键的区别显然是使用了
    realpath()
    。很高兴听到这个消息!PHP有一些奇怪的东西,这就是其中之一。你是一个向导吗?!就这样
    realpath('.')
    在我的例子中,因为我的
    Zend
    目录与
    require
    ing文件共享同一个目录。非常感谢你!作为旁注:我已经基于其他线程尝试了
    set\u include\u path()
    ,但关键的区别显然是使用了
    realpath()
    。很高兴听到这个消息!PHP有一些奇怪的东西,这就是其中之一。