@@ -71,6 +71,7 @@ public function __construct(string $localProjectDir)
71
71
parent ::__construct ();
72
72
$ this ->localProjectDir = $ localProjectDir ;
73
73
$ this ->guessSymfonyDirectoryStructure (Kernel::MAJOR_VERSION , Kernel::MINOR_VERSION );
74
+ $ this ->setEnvironmentVarName (Kernel::MAJOR_VERSION );
74
75
$ this ->setDefaultConfiguration ();
75
76
}
76
77
@@ -372,22 +373,19 @@ public function setDefaultConfiguration(?int $symfonyDirectoryStructureVersion =
372
373
}
373
374
374
375
if (self ::SYMFONY_2 === $ this ->_symfonyDirectoryStructureVersion ) {
375
- $ this ->_symfonyEnvironmentEnvVarName = 'SYMFONY_ENV ' ;
376
376
$ this ->setDirs ('app ' , 'app/config ' , 'app/cache ' , 'app/logs ' , 'src ' , 'app/Resources/views ' , 'web ' );
377
377
$ this ->controllersToRemove (['web/app_*.php ' ]);
378
378
$ this ->sharedFiles = ['app/config/parameters.yml ' ];
379
379
$ this ->sharedDirs = ['app/logs ' ];
380
380
$ this ->writableDirs = ['app/cache/ ' , 'app/logs/ ' ];
381
381
$ this ->dumpAsseticAssets = true ;
382
382
} elseif (self ::SYMFONY_3 === $ this ->_symfonyDirectoryStructureVersion ) {
383
- $ this ->_symfonyEnvironmentEnvVarName = 'SYMFONY_ENV ' ;
384
383
$ this ->setDirs ('bin ' , 'app/config ' , 'var/cache ' , 'var/logs ' , 'src ' , 'app/Resources/views ' , 'web ' );
385
384
$ this ->controllersToRemove (['web/app_*.php ' ]);
386
385
$ this ->sharedFiles = ['app/config/parameters.yml ' ];
387
386
$ this ->sharedDirs = ['var/logs ' ];
388
387
$ this ->writableDirs = ['var/cache/ ' , 'var/logs/ ' ];
389
388
} elseif (self ::SYMFONY_4 === $ this ->_symfonyDirectoryStructureVersion ) {
390
- $ this ->_symfonyEnvironmentEnvVarName = 'APP_ENV ' ;
391
389
$ this ->setDirs ('bin ' , 'config ' , 'var/cache ' , 'var/log ' , 'src ' , 'templates ' , 'public ' );
392
390
$ this ->controllersToRemove ([]);
393
391
$ this ->sharedDirs = ['var/log ' ];
@@ -402,6 +400,15 @@ protected function getReservedServerProperties(): array
402
400
return [Property::bin_dir, Property::config_dir, Property::console_bin, Property::cache_dir, Property::deploy_dir, Property::log_dir, Property::src_dir, Property::templates_dir, Property::web_dir];
403
401
}
404
402
403
+ /**
404
+ * Guess the directory structure of the project based on the framework version.
405
+ * Could be manually selected to a different structure on project setup, in that
406
+ * case the user should set the correct directory structure version in their
407
+ * deployment configuration.
408
+ *
409
+ * @param int $symfonyMajorVersion
410
+ * @param $symfonyMinorVersion
411
+ */
405
412
private function guessSymfonyDirectoryStructure (int $ symfonyMajorVersion , $ symfonyMinorVersion ): void
406
413
{
407
414
// TODO: Be a bit more clever and for example take composer.json extra configuration into account
@@ -414,6 +421,20 @@ private function guessSymfonyDirectoryStructure(int $symfonyMajorVersion, $symfo
414
421
}
415
422
}
416
423
424
+ /**
425
+ * Set the name of the environment variable for Symfony depending on the framework version
426
+ *
427
+ * @param int $symfonyMajorVersion
428
+ */
429
+ private function setEnvironmentVarName (int $ symfonyMajorVersion ): void
430
+ {
431
+ if ($ symfonyMajorVersion > 3 ) {
432
+ $ this ->_symfonyEnvironmentEnvVarName = 'APP_ENV ' ;
433
+ } else {
434
+ $ this ->_symfonyEnvironmentEnvVarName = 'SYMFONY_ENV ' ;
435
+ }
436
+ }
437
+
417
438
private function setDirs (string $ binDir , string $ configDir , string $ cacheDir , string $ logDir , string $ srcDir , string $ templatesDir , string $ webDir ): void
418
439
{
419
440
$ this ->binDir = $ binDir ;
0 commit comments