@@ -122,9 +122,31 @@ private function checkSymfonyVersionIsInstallable()
122
122
return $ this ;
123
123
}
124
124
125
- // validate semver syntax
126
- if (!preg_match ('/^2\.\d\.\d{1,2}$/ ' , $ this ->version )) {
127
- throw new \RuntimeException ('The Symfony version should be 2.N.M, where N = 0..9 and M = 0..99 ' );
125
+ // validate server syntax
126
+ if (!preg_match ('/^2\.\d(?:\.\d{1,2})?$/ ' , $ this ->version )) {
127
+ throw new \RuntimeException ('The Symfony version should be 2.N or 2.N.M, where N = 0..9 and M = 0..99 ' );
128
+ }
129
+
130
+ if (preg_match ('/^2\.\d$/ ' , $ this ->version )) {
131
+ // Check if we have a minor version in order to retrieve the last patch from symfony.com
132
+
133
+ $ client = new Client ();
134
+ $ versionsList = $ client ->get ('http://symfony.com/versions.json ' )->json ();
135
+
136
+ if ($ versionsList && isset ($ versionsList [$ this ->version ])) {
137
+ // Get the latest patch of the minor version the user asked
138
+ $ this ->version = $ versionsList [$ this ->version ];
139
+ } elseif ($ versionsList && !isset ($ versionsList [$ this ->version ])) {
140
+ throw new \RuntimeException (sprintf (
141
+ "The selected branch (%s) does not exist, or is not maintained. \n" .
142
+ "To solve this issue, install Symfony with the latest stable release: \n\n" .
143
+ '%s %s %s ' ,
144
+ $ this ->version ,
145
+ $ _SERVER ['PHP_SELF ' ],
146
+ $ this ->getName (),
147
+ $ this ->projectDir
148
+ ));
149
+ }
128
150
}
129
151
130
152
// 2.0, 2.1, 2.2 and 2.4 cannot be installed because they are unmaintained
@@ -241,7 +263,7 @@ private function download()
241
263
));
242
264
} else {
243
265
throw new \RuntimeException (sprintf (
244
- "The selected version (%s) couldn\ 't be downloaded because of the following error: \n%s " ,
266
+ "The selected version (%s) couldn't be downloaded because of the following error: \n%s " ,
245
267
$ this ->version ,
246
268
$ e ->getMessage ()
247
269
));
0 commit comments