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
。)
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有一些奇怪的东西,这就是其中之一。