@@ -70,21 +70,23 @@ protected function execute(InputInterface $input, OutputInterface $output): int
7070 return 1 ;
7171 }
7272
73- $ envFiles = $ this ->getEnvFiles ();
74- $ availableFiles = array_filter ($ envFiles , fn (string $ file ) => is_file ($ this ->getFilePath ($ file )));
73+ $ filePath = $ _SERVER ['SYMFONY_DOTENV_PATH ' ] ?? $ this ->projectDirectory .\DIRECTORY_SEPARATOR .'.env ' ;
7574
76- if (\in_array ('.env.local.php ' , $ availableFiles , true )) {
77- $ io ->warning ('Due to existing dump file (.env.local.php) all other dotenv files are skipped. ' );
75+ $ envFiles = $ this ->getEnvFiles ($ filePath );
76+ $ availableFiles = array_filter ($ envFiles , fn (string $ file ) => is_file ($ file ));
77+
78+ if (\in_array (sprintf ('%s.local.php ' , $ filePath ), $ availableFiles , true )) {
79+ $ io ->warning (sprintf ('Due to existing dump file (%s.local.php) all other dotenv files are skipped. ' , $ this ->getRelativeName ($ filePath )));
7880 }
7981
80- if (is_file ($ this -> getFilePath ( ' .env ' )) && is_file ($ this -> getFilePath ( ' .env. dist ' ))) {
81- $ io ->warning ('The file .env. dist gets skipped due to the existence of .env. ' );
82+ if (is_file ($ filePath ) && is_file (sprintf ( ' %s. dist ', $ filePath ))) {
83+ $ io ->warning (sprintf ( 'The file %s. dist gets skipped due to the existence of %1$s. ' , $ this -> getRelativeName ( $ filePath )) );
8284 }
8385
8486 $ io ->section ('Scanned Files (in descending priority) ' );
85- $ io ->listing (array_map (static fn (string $ envFile ) => \in_array ($ envFile , $ availableFiles , true )
86- ? sprintf ('<fg=green>✓</> %s ' , $ envFile )
87- : sprintf ('<fg=red>⨯</> %s ' , $ envFile ), $ envFiles ));
87+ $ io ->listing (array_map (fn (string $ envFile ) => \in_array ($ envFile , $ availableFiles , true )
88+ ? sprintf ('<fg=green>✓</> %s ' , $ this -> getRelativeName ( $ envFile) )
89+ : sprintf ('<fg=red>⨯</> %s ' , $ this -> getRelativeName ( $ envFile) ), $ envFiles ));
8890
8991 $ nameFilter = $ input ->getArgument ('filter ' );
9092 $ variables = $ this ->getVariables ($ availableFiles , $ nameFilter );
@@ -93,7 +95,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
9395
9496 if ($ variables || null === $ nameFilter ) {
9597 $ io ->table (
96- array_merge (['Variable ' , 'Value ' ], $ availableFiles ),
98+ array_merge (['Variable ' , 'Value ' ], array_map ( $ this -> getRelativeName (...), $ availableFiles) ),
9799 $ this ->getVariables ($ availableFiles , $ nameFilter )
98100 );
99101
@@ -147,36 +149,38 @@ private function getAvailableVars(): array
147149 return $ vars ;
148150 }
149151
150- private function getEnvFiles (): array
152+ private function getEnvFiles (string $ filePath ): array
151153 {
152154 $ files = [
153- ' .env. local.php ' ,
154- sprintf ('.env. %s.local ' , $ this ->kernelEnvironment ),
155- sprintf ('.env. %s ' , $ this ->kernelEnvironment ),
155+ sprintf ( ' %s. local.php ', $ filePath ) ,
156+ sprintf ('%s. %s.local ' , $ filePath , $ this ->kernelEnvironment ),
157+ sprintf ('%s. %s ' , $ filePath , $ this ->kernelEnvironment ),
156158 ];
157159
158160 if ('test ' !== $ this ->kernelEnvironment ) {
159- $ files [] = ' .env. local ' ;
161+ $ files [] = sprintf ( ' %s. local ', $ filePath ) ;
160162 }
161163
162- if (!is_file ($ this -> getFilePath ( ' .env ' )) && is_file ($ this -> getFilePath ( ' .env. dist ' ))) {
163- $ files [] = ' .env. dist ' ;
164+ if (!is_file ($ filePath ) && is_file (sprintf ( ' %s. dist ', $ filePath ))) {
165+ $ files [] = sprintf ( ' %s. dist ', $ filePath ) ;
164166 } else {
165- $ files [] = ' .env ' ;
167+ $ files [] = $ filePath ;
166168 }
167169
168170 return $ files ;
169171 }
170172
171- private function getFilePath (string $ file ): string
173+ private function getRelativeName (string $ filePath ): string
172174 {
173- return $ this ->projectDirectory .\DIRECTORY_SEPARATOR .$ file ;
175+ if (str_starts_with ($ filePath , $ this ->projectDirectory )) {
176+ return substr ($ filePath , \strlen ($ this ->projectDirectory ) + 1 );
177+ }
178+
179+ return basename ($ filePath );
174180 }
175181
176- private function loadValues (string $ file ): array
182+ private function loadValues (string $ filePath ): array
177183 {
178- $ filePath = $ this ->getFilePath ($ file );
179-
180184 if (str_ends_with ($ filePath , '.php ' )) {
181185 return include $ filePath ;
182186 }
0 commit comments