Skip to content

Commit e28fc5d

Browse files
committed
CRAFT_DOTENV_PATH + @DotEnv alias
Resolves #11894
1 parent c25e438 commit e28fc5d

File tree

3 files changed

+4
-1
lines changed

3 files changed

+4
-1
lines changed

CHANGELOG-WIP.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
- Added the `|float` Twig filter. ([#11792](https://github.com/craftcms/cms/pull/11792))
1212
- Added the `|integer` Twig filter. ([#11792](https://github.com/craftcms/cms/pull/11792))
1313
- Added the `|string` Twig filter. ([#11792](https://github.com/craftcms/cms/pull/11792))
14+
- Added support for the `CRAFT_DOTENV_PATH` PHP constant. ([#11894](https://github.com/craftcms/cms/discussions/11894))
1415
- Added `craft\db\ActiveQuery::collect()`. ([#11842](https://github.com/craftcms/cms/pull/11842))
1516
- Added `craft\elements\actions\Restore::$restorableElementsOnly`.
1617
- Added `craft\enums\DateRangeType`.

bootstrap/bootstrap.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@
8181
$rootPath = $findConfigPath('--basePath', 'CRAFT_BASE_PATH') ?? dirname($vendorPath);
8282

8383
// By default the remaining directories will be in the base directory
84+
$dotenvPath = $findConfigPath('--dotenvPath', 'CRAFT_DOTENV_PATH') ?? "$rootPath/.env";
8485
$configPath = $findConfigPath('--configPath', 'CRAFT_CONFIG_PATH') ?? "$rootPath/config";
8586
$contentMigrationsPath = $findConfigPath('--contentMigrationsPath', 'CRAFT_CONTENT_MIGRATIONS_PATH') ?? "$rootPath/migrations";
8687
$storagePath = $findConfigPath('--storagePath', 'CRAFT_STORAGE_PATH') ?? "$rootPath/storage";
@@ -200,6 +201,7 @@
200201
Craft::setAlias('@lib', $libPath);
201202
Craft::setAlias('@craft', $srcPath);
202203
Craft::setAlias('@appicons', $srcPath . DIRECTORY_SEPARATOR . 'icons');
204+
Craft::setAlias('@dotenv', $dotenvPath);
203205
Craft::setAlias('@config', $configPath);
204206
Craft::setAlias('@contentMigrations', $contentMigrationsPath);
205207
Craft::setAlias('@storage', $storagePath);

src/services/Config.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ public function getLoadingConfigFile(): ?string
322322
*/
323323
public function getDotEnvPath(): string
324324
{
325-
return $this->_dotEnvPath ?? ($this->_dotEnvPath = Craft::getAlias('@root/.env'));
325+
return $this->_dotEnvPath ?? ($this->_dotEnvPath = Craft::getAlias('@dotenv'));
326326
}
327327

328328
/**

0 commit comments

Comments
 (0)