| Markus Ernst 2007-03-29, 7:02 pm |
| l Burnerheimerton schrieb:
> --- Markus Ernst <derernst@gmx.ch> wrote:
[...][color=darkred]
>
> A clarifying question:
> Are you saying to change the Pear settings to:
> $incPath = $_SERVER['DOCUMENT_ROOT'].'/site';
> $incPath .= ':'.$incPath.'/HTML;
>
> And add the following to each page of the site:
> ini_set('include_path',
> $incPath.':'.ini_get('include_path'));
>
> or add all the those lines to each page of the php
> pages?
There is an include_path setting in the PHP ini. You can retrieve it via
ini_get('include_path'); it consists of some paths separated with ':',
and whenever you include or require a file without passing the whole
path, PHP will try to find the file prepending these paths. As when you
say require_once('Pear.php'), and usually Pear.php is not located in the
root directory, there will be an include_path such as
/usr/local/share/pear - and if Pear.php is located in this directory, it
will be included from there.
So what I suggest is, composing an include path consisting of all
possible paths needed to find the files in your PEAR installation, which
seem to be (in this order, separated with ':'s):
- the path to your /site directory
- the path to your /site/HTML directory
- the old include path, retrieved with ini_get('include_path')
And then set this new include path. If you don't append the old include
path, it will be overridden.
If you have the possibility to set this globally in the PHP ini, this
might be a good idea.
If not, you will have to set it via ini_set('include_path', $incPath).
You only have to do it once, before the first include or require
statement that calls a file in the PEAR installation, so if you can do
it in a config file or a top class file which is always called, this is
convenient.
If your application consists of 1000s of independent scripts all using
this PEAR installation, you will have to include this code in all of
them, but I think I read about some automatic prepending possibility in
the manual, this might be helpful then.
As I wrote above I am not a specialist in those web server issues,
somebody else might have more detailled comments on this.
Markus
|