Okay, I'm convinced.
The solution to my problem is to iterate get_ini('include_path')
for each included $fileName
, convert to absolute paths and process accordingly. Minimal changes to my custom include class, really. The class loader will not require any changes.
Thanks for your prompt answers!
Below are the relevant updated methods from my includer class:
( $this->includePath is initialized to get_ini('include_path') )
// Pre-condition for includeFile()
// checks if $fileName exists in the include path
public function mayIncludeFile($fileName)
{
if(array_key_exists($fileName, $this->includeMap))
{
return TRUE;
}
if($fileName{0} == DIRECTORY_SEPARATOR)
{
if(is_file($fileName))
{
$this->includeMap[$fileName] = $fileName;
return TRUE;
}
}
else foreach($this->includePath as $index => $path)
{
$absoluteFileName = $path . DIRECTORY_SEPARATOR . $fileName;
if(is_file($absoluteFileName))
{
$this->includeMap[$fileName] = $absoluteFileName;
return TRUE;
}
}
return FALSE;
}
public function includeFile($fileName)
{
$this->validateFileName($fileName, TRUE);
if((array_key_exists($fileName, $this->includeMap) && $this->includeMap[$fileName]) ||
$this->mayIncludeFile($fileName))
{
include_once($this->includeMap[$fileName]);
}
}