function find_root in Composer Manager 8
Returns the absolute path to Drupal's root directory.
File
- scripts/
init.php, line 24
Code
function find_root() {
$currentPath = getcwd() . '/';
$relativePath = '';
$rootPath = '';
$found = FALSE;
while (!$found) {
$rootPath = $currentPath . $relativePath;
if (is_dir($rootPath . 'vendor')) {
$found = TRUE;
break;
}
else {
$relativePath .= '../';
if (realpath($rootPath) === '/') {
break;
}
}
}
return $found ? realpath($rootPath) : NULL;
}