public function findMagentoRootDir($start_directory)
{
$ds = DIRECTORY_SEPARATOR;
$directory_tree = explode($ds, $start_directory);
while (count($directory_tree) > 0) {
$current_directory = join($ds, $directory_tree);
$current_search_location = join($ds, array_merge($directory_tree, array('app', 'Mage.php')));
if (file_exists($current_search_location)) {
return $current_directory;
}
array_pop($directory_tree);
}
throw new \Exception("Unable to locate Magento root");
}