Re: Re: trouble moving existing site that has "self-contained" Pear packages defined within own directories

From: Date: Thu, 29 Mar 2007 14:43:38 +0000
Subject: Re: Re: trouble moving existing site that has "self-contained" Pear packages defined within own directories
References: 1 2  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-26942@lists.php.net to get a copy of this message
l Burnerheimerton schrieb:
--- Markus Ernst <derernst@gmx.ch> wrote:
If you still have access to the old server, it might be useful to check possible include_path settings at all levels. If not, try to compare the original PEAR directory structure with the one at your server, and add include_paths, such as: $incPath = $_SERVER['DOCUMENT_ROOT'].'/site'; $incPath .= ':'.$incPath.'/HTML; ini_set('include_path', $incPath.':'.ini_get('include_path')); This will find PEAR.php in /site/HTML/, and also HTML/Common.php in /site/; and as you append the original include path, the rest of your application will not be affected. Of course you will have to delete all appearances of ini_set('include_path','.:..') and such, as this overrides your include_path settings. [...]
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

« previous php.pear.general (#26942) next »