13
13
use Symfony \Component \Console \Input \InputInterface ;
14
14
use Symfony \Component \Console \Output \OutputInterface ;
15
15
use Symfony \Component \Filesystem \Filesystem ;
16
+ use Symfony \Component \Process \PhpExecutableFinder ;
17
+ use Symfony \Component \Process \Process ;
16
18
17
19
/**
18
20
* This command creates new Symfony projects for the given Symfony version.
@@ -294,15 +296,17 @@ private function displayInstallationResult()
294
296
{
295
297
if (empty ($ this ->requirementsErrors )) {
296
298
$ this ->output ->writeln (sprintf (
297
- " <info>%s</info> Symfony was <info>successfully installed</info>. Now you can: \n" ,
298
- defined ('PHP_WINDOWS_VERSION_BUILD ' ) ? 'OK ' : '✔ '
299
+ " <info>%s</info> Symfony %s was <info>successfully installed</info>. Now you can: \n" ,
300
+ defined ('PHP_WINDOWS_VERSION_BUILD ' ) ? 'OK ' : '✔ ' ,
301
+ $ this ->getInstalledSymfonyVersion ()
299
302
));
300
303
} else {
301
304
$ this ->output ->writeln (sprintf (
302
- " <comment>%s</comment> Symfony was <info>successfully installed</info> but your system doesn't meet its \n" .
305
+ " <comment>%s</comment> Symfony %s was <info>successfully installed</info> but your system doesn't meet its \n" .
303
306
" technical requirements! Fix the following issues before executing \n" .
304
307
" your Symfony application: \n" ,
305
- defined ('PHP_WINDOWS_VERSION_BUILD ' ) ? 'FAILED ' : '✕ '
308
+ defined ('PHP_WINDOWS_VERSION_BUILD ' ) ? 'FAILED ' : '✕ ' ,
309
+ $ this ->getInstalledSymfonyVersion ()
306
310
));
307
311
308
312
foreach ($ this ->requirementsErrors as $ helpText ) {
@@ -318,13 +322,13 @@ private function displayInstallationResult()
318
322
}
319
323
320
324
$ this ->output ->writeln (sprintf (
321
- " * Change your current directory to %s. \n" .
325
+ " * Change your current directory to <comment>%s</comment> \n \n" .
322
326
" * Configure your application in <comment>app/config/parameters.yml</comment> file. \n\n" .
323
327
" * Run your application: \n" .
324
328
" 1. Execute the <comment>php app/console server:run</comment> command. \n" .
325
329
" 2. Browse to the <comment>http://localhost:8000</comment> URL. \n\n" .
326
330
" * Read the documentation at <comment>http://symfony.com/doc</comment> \n" ,
327
- $ this ->projectName
331
+ $ this ->projectDir
328
332
));
329
333
330
334
return $ this ;
@@ -378,4 +382,22 @@ private function getErrorMessage(\Requirement $requirement, $lineSize = 70)
378
382
379
383
return $ errorMessage ;
380
384
}
385
+
386
+ /**
387
+ * It returns the full Symfony version number of the project by executing
388
+ * the '$ ./app/console --version' command, which outputs the following:
389
+ * Symfony version X.Y.Z - app/dev/debug
390
+ */
391
+ private function getInstalledSymfonyVersion ()
392
+ {
393
+ $ composer = json_decode (file_get_contents ($ this ->projectDir .'/composer.lock ' ), true );
394
+
395
+ foreach ($ composer ['packages ' ] as $ package ) {
396
+ if ('symfony/symfony ' !== $ package ['name ' ]) {
397
+ continue ;
398
+ }
399
+
400
+ return $ package ['version ' ];
401
+ }
402
+ }
381
403
}
0 commit comments