You are here

function find_root in Composer Manager 8

Returns the absolute path to Drupal's root directory.

1 call to find_root()
init.php in scripts/init.php

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;
}