From 35dbb9541b6ea1abbe45378f13d7314f127a07f1 Mon Sep 17 00:00:00 2001 From: David Grudl Date: Wed, 8 May 2024 21:57:16 +0200 Subject: [PATCH] fixed rootDir detection in older Composer --- src/Bootstrap/Configurator.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Bootstrap/Configurator.php b/src/Bootstrap/Configurator.php index e57383f..6d5321a 100644 --- a/src/Bootstrap/Configurator.php +++ b/src/Bootstrap/Configurator.php @@ -169,13 +169,14 @@ protected function getDefaultParameters(): array $loaderRc = class_exists(ClassLoader::class) ? new \ReflectionClass(ClassLoader::class) : null; + $rootDir = class_exists(InstalledVersions::class) && ($tmp = InstalledVersions::getRootPackage()['install_path'] ?? null) + ? rtrim(Nette\Utils\FileSystem::normalizePath($tmp), '\\/') + : null; return [ 'appDir' => isset($trace[1]['file']) ? dirname($trace[1]['file']) : null, 'wwwDir' => isset($last['file']) ? dirname($last['file']) : null, 'vendorDir' => $loaderRc ? dirname($loaderRc->getFileName(), 2) : null, - 'rootDir' => class_exists(InstalledVersions::class) - ? rtrim(Nette\Utils\FileSystem::normalizePath(InstalledVersions::getRootPackage()['install_path']), '\\/') - : null, + 'rootDir' => $rootDir, 'debugMode' => $debugMode, 'productionMode' => !$debugMode, 'consoleMode' => PHP_SAPI === 'cli',