@@ -9,26 +9,42 @@ function copyFile(array $file): void
99 if (is_readable ($ file ['destination ' ])) {
1010 echo "File {$ file ['destination ' ]} already exists. " . PHP_EOL ;
1111 } else {
12- if (! copy ( $ file ['source ' ], $ file [ ' destination ' ]) ) {
13- echo "Cannot copy {$ file ['source ' ]} file to { $ file [ ' destination ' ]} " . PHP_EOL ;
12+ if (! isDevModeEnabled () && $ file ['environment ' ] === ' local ' ) {
13+ echo "Skipping the copy of {$ file ['source ' ]} due to environment settings. " . PHP_EOL ;
1414 } else {
15- echo "File {$ file ['source ' ]} copied successfully to {$ file ['destination ' ]}. " . PHP_EOL ;
15+ if (! copy ($ file ['source ' ], $ file ['destination ' ])) {
16+ echo "Cannot copy {$ file ['source ' ]} file to {$ file ['destination ' ]}" . PHP_EOL ;
17+ } else {
18+ echo "File {$ file ['source ' ]} copied successfully to {$ file ['destination ' ]}. " . PHP_EOL ;
19+ }
1620 }
1721 }
1822}
1923
24+ function isDevModeEnabled (): bool
25+ {
26+ return file_exists ('config/autoload/development.local.php ' );
27+ }
28+
29+ // when adding files to the below array the `source` and `destination` must be relative to the project root folder
30+ // the `environment` key will indicate when the file should be copied,
31+ // if the value is `production` the file will be copied on both production and local environments,
32+ // if the value is `local` the file will be copied only on local environments
2033$ files = [
2134 [
2235 'source ' => 'config/autoload/local.php.dist ' ,
2336 'destination ' => 'config/autoload/local.php ' ,
37+ 'environment ' => 'production ' ,
2438 ],
2539 [
2640 'source ' => 'config/autoload/local.test.php.dist ' ,
2741 'destination ' => 'config/autoload/local.test.php ' ,
42+ 'environment ' => 'local ' ,
2843 ],
2944 [
3045 'source ' => 'vendor/dotkernel/dot-mail/config/mail.global.php.dist ' ,
3146 'destination ' => 'config/autoload/mail.global.php ' ,
47+ 'environment ' => 'production ' ,
3248 ],
3349];
3450
0 commit comments