I have a lot of functions and classes that I have included in my website. With the help of stackoverflow I recieved a script that automaticly includes all files in a folder and its subfolders: PHP: Automatic Include
When testing the script it always worked and I never had any problems with it. But recently when switching from a windows server to a linux server it gives problems with extension of classes.
PHP Fatal error: Class 'AcumulusExportBase' not found in path/functions/classes/Acumulus/AcumulusExportWorkshop.php on line 3, referer: pagesite/?page_id=346
AcumulusExportWorkshop extends from AcumulusExportBase. This all fully works on windows but refuses to work on linux.
I can fix this creating a include_once 'AcumulusExportBase.php'; but if there is a better solution it all seems unnecessary and annyoing work.
The code I use is the following:
load_folder(dirname(__FILE__));
function load_folder($dir, $ext = '.php') {
if (substr($dir, -1) != '/') { $dir = "$dir/"; }
if($dh = opendir($dir)) {
$files = array();
$inner_files = array();
while($file = readdir($dh)) {
if($file != "." and $file != ".." and $file[0] != '.') {
if(is_dir($dir . $file)) {
$inner_files = load_folder($dir . $file);
if(is_array($inner_files)) $files = array_merge($files, $inner_files);
} else {
array_push($files, $dir . $file);
}
}
}
closedir($dh);
foreach ($files as $file) {
if (is_file($file) and file_exists($file)) {
$lenght = strlen($ext);
if (substr($file, -$lenght) == $ext && $file != 'loader.php') { require_once($file); }
}
}
}
}
Can anyone tell me how it is that windows has no problems with extension classes and linux does? Also is there a fix for the problem without having to manual include the base classes?