开发者

include_path doesn't recurse?

开发者 https://www.devze.com 2023-01-12 16:35 出处:网络
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.

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 ther开发者_StackOverflow中文版e 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


EDIT: You want to change your include_path to include /var/www/common_files

What, if anything, is still broken after you do this?


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


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.


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'
0

精彩评论

暂无评论...
验证码 换一张
取 消