Re: Rethink CS for require_once?
| From: | Lukas Smith | Date: | Thu, 02 Dec 2004 09:15:16 +0000 |
| Subject: | Re: Rethink CS for require_once? | ||
| References: | 1 2 3 4 5 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-34718@lists.php.net to get a copy of this message | ||
Greg Beaver wrote:
Lukas Smith wrote:<snip>Greg Beaver wrote:The problem Stig is talking about would only come about if a package is included as both require_once 'DB/mysql.php'; and as require_once dirname(__FILE__) . '/mysql.php'; As I said, if any file *can* be used by itself, then it is disqualified from the dirname(__FILE__) rule. Otherwise, the only inclusion code will be either:Andrew Nagy wrote:I still dont see how your solution will work around the issues stated in Stig's post that Alan linked to. Also remember that different packages will include a given package. So you also need to take into account that its not always the user that includes a given package.I don't know if this has been discussed before, but what about using just require for internal packages and require_once for external? Rasmus Lerdorf mentioned at a PHP conference that require_once is really slow and should be avoided at all costs. Considering the app programmer most likely will not be including files buried deep with in a pear package, this may be more beneficial?I think the disadvantages outweigh the benefits - remember, I'm not looking for a performance gain, that's just an added benefit in some situations. Most important is the security of knowing that internal files will only come from one place.
There is no conflict, because it is not possible to include the file in both ways (is not allowed by convention). In the past, the proposal was to use dirname(__FILE__) for every internal file. This is impossible, it can only be limited to every *private* internal file.maybe I still dont get it but what if a package requires DB and the users code also requires DB. So the users does: require 'foo/bar/DB.php'; then he does: require 'foo/lala/DB/NestedSet.php'; NestedSet will also load DB.php but relative to the foo/lala path. So again unless we do a class_exists() before any call inside PEAR that loads another class we hit a brick wall. Actually even worse DB.php is a public file so NestedSet should not use dirname(__FILE__) according to your argument!(?) regards, Lukas