-
Notifications
You must be signed in to change notification settings - Fork 114
Added more information about project installed #64
Conversation
b028beb
to
9713c70
Compare
|
||
private function getInstalledProjectVersion() | ||
{ | ||
$getVersion = new Process('php ./'.$this->projectName.'/app/console --version'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use PhpExecutableFinder
instead of calling directly php
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea.
485af40
to
ac42f19
Compare
@@ -378,4 +391,24 @@ private function getErrorMessage(\Requirement $requirement, $lineSize = 70) | |||
|
|||
return $errorMessage; | |||
} | |||
|
|||
private function getInstalledProjectVersion() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For now it's OK to use this method to get the installed version ... but soon, when we improve the way we get the Symfony version to be installed, this code will be unnecessary because we already know the exact version before installing Symfony.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually I feel that way is "safer" as we are obsolutely sure about the version of has been installed.
@saro0h I really like the idea of displaying the exact installed version of Symfony. That's a nice improvement! Thank you. However, I don't like the idea to make the result message longer with so many lines. We're completely obsessed with streamlining the installation experience as much as possible and therefore, every line counts. That's why I propose you to simplify a bit your proposal as follows: If you agree, this is the patch with the required changes: diff --git a/src/Symfony/Installer/NewCommand.php b/src/Symfony/Installer/NewCommand.php
index 56b11f8..1603b41 100755
--- a/src/Symfony/Installer/NewCommand.php
+++ b/src/Symfony/Installer/NewCommand.php
@@ -295,27 +295,18 @@ class NewCommand extends Command
private function displayInstallationResult()
{
if (empty($this->requirementsErrors)) {
- $versionInstalled = $this->getInstalledProjectVersion();
- $folderInstalled = $this->getProjectFolder();
- $tick = defined('PHP_WINDOWS_VERSION_BUILD') ? 'OK' : '✔';
-
$this->output->writeln(sprintf(
- " <info>%s</info> Symfony was <info>successfully installed</info>.\n".
- " <info>%s</info> Your new project is using <info>%s</info>.\n".
- " <info>%s</info> Your project is here: <comment>%s</comment>.\n\n".
- " Now you can:",
- $tick,
- $tick,
- $versionInstalled,
- $tick,
- $folderInstalled
+ " <info>%s</info> Symfony %s was <info>successfully installed</info>. Now you can:\n",
+ defined('PHP_WINDOWS_VERSION_BUILD') ? 'OK' : '✔',
+ $this->getInstalledSymfonyVersion()
));
} else {
$this->output->writeln(sprintf(
- " <comment>%s</comment> Symfony was <info>successfully installed</info> but your system doesn't meet its\n".
+ " <comment>%s</comment> Symfony %s was <info>successfully installed</info> but your system doesn't meet its\n".
" technical requirements! Fix the following issues before executing\n".
" your Symfony application:\n",
- defined('PHP_WINDOWS_VERSION_BUILD') ? 'FAILED' : '✕'
+ defined('PHP_WINDOWS_VERSION_BUILD') ? 'FAILED' : '✕',
+ $this->getInstalledSymfonyVersion()
));
foreach ($this->requirementsErrors as $helpText) {
@@ -331,13 +322,13 @@ class NewCommand extends Command
}
$this->output->writeln(sprintf(
- " * Change your current directory to %s.\n".
+ " * Change your current directory to <comment>%s</comment>\n\n".
" * Configure your application in <comment>app/config/parameters.yml</comment> file.\n\n".
" * Run your application:\n".
" 1. Execute the <comment>php app/console server:run</comment> command.\n".
" 2. Browse to the <comment>http://localhost:8000</comment> URL.\n\n".
" * Read the documentation at <comment>http://symfony.com/doc</comment>\n",
- $this->projectName
+ $this->projectDir
));
return $this;
@@ -392,7 +383,12 @@ class NewCommand extends Command
return $errorMessage;
}
- private function getInstalledProjectVersion()
+ /**
+ * It returns the full Symfony version number of the project by executing
+ * the '$ ./app/console --version' command, which outputs the following:
+ * Symfony version X.Y.Z - app/dev/debug
+ */
+ private function getInstalledSymfonyVersion()
{
$phpExecutableFinder = new PhpExecutableFinder();
$php = $phpExecutableFinder->find();
@@ -404,11 +400,6 @@ class NewCommand extends Command
throw new \RuntimeException($getVersion->getErrorOutput());
}
- return substr($getVersion->getOutput(), 0, strlen($getVersion->getOutput())-17);
- }
-
- private function getProjectFolder()
- {
- return str_replace("\n", '', getcwd().'/'.$this->projectName);
+ return substr($getVersion->getOutput(), 16, 5);
}
} |
8eaa715
to
6f9b2f8
Compare
throw new \RuntimeException('The php binary cannot be found.'); | ||
} | ||
|
||
$getVersion = new Process($php.' ./'.$this->projectName.'/app/console --version'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should use the ProcessBuilder here, in order to escape these arguments. In case $this->projectName
contains special chars or space, this command could fail.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why don't use composer directly ?
<?php
function get_symfony_version()
{
$composer = json_decode(file_get_contents(__DIR__.'/composer.lock'), true);
foreach ($composer['packages'] as $package) {
if ('symfony/symfony' !== $package['name']) {
continue;
}
return $package['version'];
}
}
echo get_symfony_version();
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think @lyrixx's proposal is really the way to go: simple, fast and it should always work without problems.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok i'll do that.
Nice job ! |
fc38bad
to
1b35f2a
Compare
Here you go. Thanks @lyrixx for the tip :) |
f9a3313
to
6cffdd9
Compare
👍 Thank you Sarah for improving the installer! |
6cffdd9
to
83c8b2d
Compare
👍 |
|
||
/** | ||
* Returns the full Symfony version number of the project by getting | ||
* it in the composer.lock file. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[...] getting it from the [...]?
Thank you @saro0h. |
This PR was merged into the 1.0-dev branch. Discussion ---------- Added more information about project installed Before enhancement:  After enhancement:  Commits ------- 83c8b2d Added more information about project installed
Before enhancement:

After enhancement:
