include_path 不递归?
我有几个单独的网站,位于不同的目录中。对于它们的共同点,我将其放在其余部分所在的根目录中。
user@hostname:/var/www$ ls
website_1 website_2 website_3 common_files
我想包含一个 Zend 包,所以我的包含路径
ini_set("include_path", get_include_path() . ":/var/www/common_files/Zend");
require_once("Mail.php");
Mail.php
加载正常,但是在某处有这一行
require_once 'Zend/Mail/Transport/Abstract.php';
给出了这个错误
Warning: require_once(Zend/Mail/Transport/Abstract.php): failed to open stream: No such file or directory in var/www/common_files/Zend/Mail.php on line 26
所以 php 不会递归地下降到目录结构中的包含路径。我是否必须将 Zend 移动到每个网站目录中,阐明每个包含的路径,或者什么?
顺便说一句,摘要确实存在:
user@host:/var/www/common_files/Zend$ tree -d
...
`-- Mail/Transport
|-- Mail/Transport/Abstract.php
|-- Mail/Transport/Exception.php
|-- Mail/Transport/Sendmail.php
`-- Mail/Transport/Smtp.php
9 directories, 32 files
I have several separate websites that live in separate directories. For includes that they have in common, I have it living in the root directory where the rest of them live.
user@hostname:/var/www$ ls
website_1 website_2 website_3 common_files
I want to include a Zend package, so I have my include path
ini_set("include_path", get_include_path() . ":/var/www/common_files/Zend");
require_once("Mail.php");
Mail.php
loads okay, but then somewhere in there is this line
require_once 'Zend/Mail/Transport/Abstract.php';
which gives this error
Warning: require_once(Zend/Mail/Transport/Abstract.php): failed to open stream: No such file or directory in var/www/common_files/Zend/Mail.php on line 26
So php doesn't recursively descend into the directory structure of the include paths. Do I have to move Zend into each website direcory, spell out the path to every include, or what?
BTW Abstract does exist:
user@host:/var/www/common_files/Zend$ tree -d
...
`-- Mail/Transport
|-- Mail/Transport/Abstract.php
|-- Mail/Transport/Exception.php
|-- Mail/Transport/Sendmail.php
`-- Mail/Transport/Smtp.php
9 directories, 32 files
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
编辑:您想要更改 include_path 以包含
/var/www/common_files
执行此操作后,什么(如果有的话)仍然损坏?
EDIT: You want to change your include_path to include
/var/www/common_files
What, if anything, is still broken after you do this?
愚蠢的答案:Abstract.php存在吗?
试试这个,因为 Mail.php iz 已经在 Zend 文件夹中,我猜它会寻找 /Zend/Zend/.../Abstract.php
Stupid answer: Does Abstract.php exist?
Try this, because Mail.php iz already in Zend folder, I guess it looks for /Zend/Zend/.../Abstract.php
看起来
Zend
是这里的工作目录,因此您的语句正在查找/Zend/Zend/Mail/Transport/Abstract.php
。尝试从语句中删除Zend
,它应该可以正常工作。It looks like
Zend
is the working directory here, so your statement is looking for/Zend/Zend/Mail/Transport/Abstract.php
. Try just cutting offZend
from the statement and it should work fine.您需要将包含路径设置为 Zend 文件夹所在的路径。然后你像这样包含文件
you need to set your include path to the path where the Zend folder is. then you include the files like so