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");
    }
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");
    }
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" ) ; }
Given a start directory, work upwards and attempt to identify the Magento root directory.  Throws an
exception if it can't be found.

@param string $start_directory
@return string
@throws \Exception
Given a start directory work upwards and attempt to identify the Magento root directory . Throws an exception if it can t be found .