diff --git a/config.stub.neon b/config.stub.neon index dc51281..056d123 100644 --- a/config.stub.neon +++ b/config.stub.neon @@ -4,6 +4,7 @@ parameters: wwwDir: absolute path to the directory containing the index.php entry file tempDir: absolute path to the directory for temporary files vendorDir: absolute path to the directory where Composer installs libraries + rootDir: absolute path to the root project directory debugMode: indicates whether the application is in debug mode productionMode: opposite of debugMode consoleMode: indicates whether the request came through the command line (CLI) diff --git a/src/Bootstrap/Configurator.php b/src/Bootstrap/Configurator.php index 704e201..1b06830 100644 --- a/src/Bootstrap/Configurator.php +++ b/src/Bootstrap/Configurator.php @@ -173,6 +173,9 @@ protected function getDefaultParameters(): array '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, 'debugMode' => $debugMode, 'productionMode' => !$debugMode, 'consoleMode' => PHP_SAPI === 'cli', diff --git a/tests/Bootstrap/Configurator.developmentContainer.phpt b/tests/Bootstrap/Configurator.developmentContainer.phpt index 0b0168d..fa25565 100644 --- a/tests/Bootstrap/Configurator.developmentContainer.phpt +++ b/tests/Bootstrap/Configurator.developmentContainer.phpt @@ -37,6 +37,7 @@ Assert::same([ 'appDir' => __DIR__, 'wwwDir' => __DIR__, 'vendorDir' => dirname(__DIR__, 2) . DIRECTORY_SEPARATOR . 'vendor', + 'rootDir' => dirname(__DIR__, 2), 'debugMode' => true, 'productionMode' => false, 'consoleMode' => PHP_SAPI === 'cli', diff --git a/tests/Bootstrap/Configurator.minimalContainer.phpt b/tests/Bootstrap/Configurator.minimalContainer.phpt index 86b7a77..1c8e5a9 100644 --- a/tests/Bootstrap/Configurator.minimalContainer.phpt +++ b/tests/Bootstrap/Configurator.minimalContainer.phpt @@ -26,6 +26,7 @@ Assert::same([ 'appDir' => __DIR__, 'wwwDir' => __DIR__, 'vendorDir' => dirname(__DIR__, 2) . DIRECTORY_SEPARATOR . 'vendor', + 'rootDir' => dirname(__DIR__, 2), 'debugMode' => false, 'productionMode' => true, 'consoleMode' => PHP_SAPI === 'cli',