function DrupalKernel::guessApplicationRoot

Same name and namespace in other branches
  1. 11.x core/lib/Drupal/Core/DrupalKernel.php \Drupal\Core\DrupalKernel::guessApplicationRoot()
  2. 9 core/lib/Drupal/Core/DrupalKernel.php \Drupal\Core\DrupalKernel::guessApplicationRoot()
  3. 8.9.x core/lib/Drupal/Core/DrupalKernel.php \Drupal\Core\DrupalKernel::guessApplicationRoot()

Determine the application root directory based on this file's location.

Return value

string The application root.

File

core/lib/Drupal/Core/DrupalKernel.php, line 336

Class

DrupalKernel
The DrupalKernel class is the core of Drupal itself.

Namespace

Drupal\Core

Code

protected static function guessApplicationRoot() {
  // Determine the application root by:
  // - Removing the namespace directories from the path.
  // - Getting the path to the directory two levels up from the path
  //   determined in the previous step.
  return dirname(substr(__DIR__, 0, -strlen(__NAMESPACE__)), 2);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.