I just tried the following two approaches. I created the file MWInit.php in my .../phase3 directory with the following code:
<?php
function MWInit() {
$IP = strval( getenv('MW_INSTALL_PATH') ) !== '' ? getenv('MW_INSTALL_PATH') : realpath( dirname( __FILE__ ));
return $IP; }
I then modified include_path in php.ini to include my ../phase3 directory. In phase3/maintenance I created the file GetIP.php with the following code:
<?php
require_once('MWInit.php');
$IP = MWInit(); ?>
This worked. $IP was set to the correct value.
However, Dmitriy Sintsov makes the excellent point that not everyone can change php.ini. So, I then put MWInit.php into the PEAR directory and modified it as follows:
<?php
function MWInit() {
$IP = "/Volumes/Macintosh 2nd HD/DataBucket/Wiki Work/Code Development/LatestTrunkVersion/phase3";
return $IP; }
I removed my ../phase3 directory from include_path in php.ini and once again ran GetIP.php. $IP was returned successfully.
The question may arise, how do you get the value of the MW root into MWInit.php in the first place? This can occur on MW installation. Of course, there may be a problem getting MWInit.php into the PEAR directory, but I assume that is an easier task than modifying php.ini. However, if even this is a problem, then we can do what Dmitry suggests, set an environmental variable to the MW root path.
As I pointed out before, there may be better ways of automatically getting the value of $IP. However, I don't think it requires any manual effort.