include_path 不递归?

发布于 2024-09-14 22:14:41 字数 989 浏览 0 评论 0原文

我有几个单独的网站,位于不同的目录中。对于它们的共同点,我将其放在其余部分所在的根目录中。

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 技术交流群。

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

发布评论

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

评论(4

后来的我们 2024-09-21 22:14:41

编辑:您想要更改 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?

々眼睛长脚气 2024-09-21 22:14:41

愚蠢的答案:Abstract.php存在吗?

require_once 'Mail/Transport/Abstract.php';

试试这个,因为 Mail.php iz 已经在 Zend 文件夹中,我猜它会寻找 /Zend/Zend/.../Abstract.php

Stupid answer: Does Abstract.php exist?

require_once 'Mail/Transport/Abstract.php';

Try this, because Mail.php iz already in Zend folder, I guess it looks for /Zend/Zend/.../Abstract.php

江湖彼岸 2024-09-21 22:14:41

看起来 Zend 是这里的工作目录,因此您的语句正在查找 /Zend/Zend/Mail/Transport/Abstract.php。尝试从语句中删除 Zend ,它应该可以正常工作。

It looks like Zendis the working directory here, so your statement is looking for /Zend/Zend/Mail/Transport/Abstract.php. Try just cutting off Zend from the statement and it should work fine.

少女的英雄梦 2024-09-21 22:14:41

您需要将包含路径设置为 Zend 文件夹所在的路径。然后你像这样包含文件

require_once 'Zend/Mail.php'

you need to set your include path to the path where the Zend folder is. then you include the files like so

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