Get the path to the Composer root directory.
public function getComposerRoot() : ?string { foreach (InstalledVersions::getAllRawData() as $data) { if (isset($data['versions']['drupal/core'])) { return realpath($data['root']['install_path']); } } $root = InstalledVersions::getRootPackage(); return realpath($root['install_path']); }