Skip to content
This repository was archived by the owner on Nov 14, 2019. It is now read-only.

Commit f0d03d5

Browse files
committed
feature #185 Improve the installation of -dev and -BETA versions (94noni, javiereguiluz)
This PR was merged into the 1.0-dev branch. Discussion ---------- Improve the installation of -dev and -BETA versions This finishes #159, which is related to #144 and #143. The new behavior of the installer: 1) When installing a regular Symfony version, nothing changes from the previous installer. 2) When you install a `beta` version, you see a warning message: ![symfony-unstable-warning](https://cloud.githubusercontent.com/assets/73419/9811676/f14b6d02-5878-11e5-9220-301fcb671c8c.png) 3) When you try to install a `dev` version, you get a better error message and a link to the article that will solve your problem: ![symfony-dev-version](https://cloud.githubusercontent.com/assets/73419/9811642/c0bdc194-5878-11e5-9ee8-9af5e194f80b.png) Commits ------- 6751701 Fixed again one test 3ea393a Fixed one test f45a29a Fixed again the version parser regexp 165813c Added new tests for BETA and RC versions 9e41335 Updated the version parser regular expression b26b217 Added support for RC versions and normalized version names 31765ca Made comparisons case insensitive because Composer doesn't differentiate 'BETA1' from 'beta1' 9b3cdc1 The trailing number is only available for BETA versions not for 'dev' versions d03938f Fixed syntax issues d67b4ad Improved the error message for "-dev" versions 4c26d2b Warn the user when downloading an unstable version 94a1f98 Simplified the new feature a bit d58812a Installation dev/beta versions (143)
2 parents daa5232 + 6751701 commit f0d03d5

File tree

2 files changed

+28
-8
lines changed

2 files changed

+28
-8
lines changed

src/Symfony/Installer/NewCommand.php

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -105,19 +105,14 @@ protected function execute(InputInterface $input, OutputInterface $output)
105105
protected function checkSymfonyVersionIsInstallable()
106106
{
107107
// 'latest' is a special version name that refers to the latest stable version
108-
// available at the moment of installing Symfony
109-
if ('latest' === $this->version) {
110-
return $this;
111-
}
112-
113108
// 'lts' is a special version name that refers to the current long term support version
114-
if ('lts' === $this->version) {
109+
if (in_array($this->version, array('latest', 'lts'))) {
115110
return $this;
116111
}
117112

118113
// validate semver syntax
119-
if (!preg_match('/^2\.\d(?:\.\d{1,2})?$/', $this->version)) {
120-
throw new \RuntimeException('The Symfony version should be 2.N or 2.N.M, where N = 0..9 and M = 0..99');
114+
if (!preg_match('/^2\.\d(?:\.\d{1,2})?(?:-(?:dev|BETA\d*|RC\d*))?$/i', $this->version)) {
115+
throw new \RuntimeException('The Symfony version must be 2.N or 2.N.M (where N and M are positive integers). The special "-dev", "-BETA" and "-RC" versions are also supported.');
121116
}
122117

123118
if (preg_match('/^2\.\d$/', $this->version)) {
@@ -175,6 +170,25 @@ protected function checkSymfonyVersionIsInstallable()
175170
));
176171
}
177172

173+
// "-dev" versions are not supported because Symfony doesn't provide packages for them
174+
if (preg_match('/^.*\-dev$/i', $this->version)) {
175+
throw new \RuntimeException(sprintf(
176+
"The selected version (%s) cannot be installed because it hasn't\n".
177+
"been published as a package yet. Read the following article for\n".
178+
"an alternative installation method:\n\n".
179+
"> How to Install or Upgrade to the Latest, Unreleased Symfony Version\n".
180+
'> http://symfony.com/doc/current/cookbook/install/unstable_versions.html',
181+
$this->version
182+
));
183+
}
184+
185+
// warn the user when downloading an unstable version
186+
if (preg_match('/^.*\-(BETA|RC)\d*$/i', $this->version)) {
187+
$this->output->writeln("\n <bg=red> WARNING </> You are downloading an unstable Symfony version.");
188+
// versions provided by the download server are case sensitive
189+
$this->version = strtoupper($this->version);
190+
}
191+
178192
return $this;
179193
}
180194

tests/Symfony/Installer/Tests/IntegrationTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,12 @@ public function provideSymfonyInstallationData()
106106
'/.*Symfony 2\.5\.6 was successfully installed.*/',
107107
'/Symfony version 2\.5\.6 - app\/dev\/debug/',
108108
),
109+
110+
array(
111+
'2.7.0-BETA1',
112+
'/.*Symfony 2\.7\.0\-BETA1 was successfully installed.*/',
113+
'/Symfony version 2\.7\.0\-BETA1 - app\/dev\/debug/',
114+
),
109115
);
110116
}
111117
}

0 commit comments

Comments
 (0)