Re: Relativ Includes
| From: | Wolfram Kriesing | Date: | Fri, 01 Nov 2002 14:16:57 +0000 |
| Subject: | Re: Relativ Includes | ||
| References: | 1 2 3 4 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-10418@lists.php.net to get a copy of this message | ||
Stig S. Bakken wrote:
Let's say we have two trees: /usr/local/lib/php (1) and /home/joe/lib/php (2). In tree 1, Foo.php requires PEAR.php, and includes it with dirname(__FILE__)."/PEAR.php"; In tree 2, Bar.php requires PEAR.php and includes it the same way. This will of course break, since when loading Bar.php you'll get redefinition errors from /home/joe/lib/php/PEAR.php. Include_once and require_once were added to PHP to solve exactly this problem. On top of this, PEAR has a standard way of mapping class names to includes, in a _single_ hierarchy. The side-effect of being able to use dirname(__FILE__) to solve your specific problem is that you break this system. Having two install trees that don't overlap may work too, having two that overlap slightly may even work on good days, but I don't think we should bend over backwards to support that. I'm open to discussing other ways to solve problems such as yours, but changing the general way files are included is not how it should be done. We can provide an interface to the *_once internal hashes or something like that instead. I think we should focus on solving two problems _first_: 1. Running tests without installing first (solved with package source directory structure) 2. Using your own pear install with ini_set() disabled and no access to web server config ala .htaccess.thank you for the answer. you are right, there are simply too many ways one can use PEAR or include|require_once ... that's true. i completely agree, that those 2 points u finally stated should be solved firt. it is right that i was thinking too much of the case that caused problems for me, good to be sure that we are discussing that :-) btw. Lukas, i think the PEAR_INCLUDE_PATH thing would also just solve it as much as using ini_set('include_path',PEAR_INCLUDE_PATH); would do. or is that wrong? so i would prefer the ini_set way, as i am also using it successfully, for my uses :-) -- Wolfram ... translating template engine .... http://sf.net/projects/simpletpl ... authentication system .... http://sf.net/projects/auth