Group/types/Class.php * Group_Class => Group/Class.php */ if ($noOfParts > 2) { $lastPart = array_pop($parts); $lastOnePart = array_pop($parts); array_push($parts, strtolower($lastPart).'s'); array_push($parts, $lastOnePart); $filename = PORTAL_APP_DIR."/classes/".implode('/', $parts).'.php'; } else if ($noOfParts > 1) { $filename = PORTAL_APP_DIR."/classes/".implode('/', $parts).'.php'; } if ($filename && file_exists($filename)) { // TODO check if the file is within webdirectory. require_once $filename; } } } spl_autoload_register('Portal_Loader::autoLoad');