File tree Expand file tree Collapse file tree 3 files changed +6
-5
lines changed
Expand file tree Collapse file tree 3 files changed +6
-5
lines changed Original file line number Diff line number Diff line change @@ -170,7 +170,8 @@ public static function preload(Paths $paths): void
170170 protected static function loadDotEnv (Paths $ paths ): void
171171 {
172172 require_once $ paths ->systemDirectory . '/Config/DotEnv.php ' ;
173- (new DotEnv ($ paths ->envDirectory ))->load ();
173+ $ envDirectory = $ paths ->envDirectory ?? $ paths ->appDirectory . '/../ ' ;
174+ (new DotEnv ($ envDirectory ))->load ();
174175 }
175176
176177 protected static function defineEnvironment (): void
Original file line number Diff line number Diff line change @@ -102,7 +102,7 @@ public function run(array $params)
102102 // force DotEnv to reload the new env vars
103103 putenv ('encryption.key ' );
104104 unset($ _ENV ['encryption.key ' ], $ _SERVER ['encryption.key ' ]);
105- $ dotenv = new DotEnv ((new Paths ())->envDirectory );
105+ $ dotenv = new DotEnv ((new Paths ())->envDirectory ?? ROOTPATH );
106106 $ dotenv ->load ();
107107
108108 CLI ::write ('Application \'s new encryption key was successfully set. ' , 'green ' );
@@ -156,7 +156,7 @@ protected function confirmOverwrite(array $params): bool
156156 protected function writeNewEncryptionKeyToFile (string $ oldKey , string $ newKey ): bool
157157 {
158158 $ baseEnv = ROOTPATH . 'env ' ;
159- $ envFile = (new Paths ())->envDirectory . '.env ' ;
159+ $ envFile = (( new Paths ())->envDirectory ?? ROOTPATH ) . '.env ' ;
160160
161161 if (! is_file ($ envFile )) {
162162 if (! is_file ($ baseEnv )) {
Original file line number Diff line number Diff line change @@ -120,7 +120,7 @@ public function run(array $params)
120120 // however we cannot redefine the ENVIRONMENT constant
121121 putenv ('CI_ENVIRONMENT ' );
122122 unset($ _ENV ['CI_ENVIRONMENT ' ], $ _SERVER ['CI_ENVIRONMENT ' ]);
123- (new DotEnv ((new Paths ())->envDirectory ))->load ();
123+ (new DotEnv ((new Paths ())->envDirectory ?? ROOTPATH ))->load ();
124124
125125 CLI ::write (sprintf ('Environment is successfully changed to "%s". ' , $ env ), 'green ' );
126126 CLI ::write ('The ENVIRONMENT constant will be changed in the next script execution. ' );
@@ -135,7 +135,7 @@ public function run(array $params)
135135 private function writeNewEnvironmentToEnvFile (string $ newEnv ): bool
136136 {
137137 $ baseEnv = ROOTPATH . 'env ' ;
138- $ envFile = (new Paths ())->envDirectory . '.env ' ;
138+ $ envFile = (new Paths ())->envDirectory ?? ROOTPATH . '.env ' ;
139139
140140 if (! is_file ($ envFile )) {
141141 if (! is_file ($ baseEnv )) {
You can’t perform that action at this time.
0 commit comments