Skip to content

Commit 64a1777

Browse files
authored
Php composer parsing (#4055)
* Fix PHP version parsed from composer.json * Adds PHP 8.3 in the php_version choices
1 parent 55b7a73 commit 64a1777

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

recipe/provision/php.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,12 @@
66
$defaultPhpVersion = file_exists('composer.json')
77
? explode('|', preg_replace('/[^0-9.|]+/', '', json_decode(file_get_contents('composer.json'), true)['require']['php'] ?? '8.3'))[0]
88
: '8.3';
9-
return ask(' What PHP version to install? ', $defaultPhpVersion, ['5.6', '7.4', '8.0', '8.1', '8.2']);
9+
10+
if (count(($parts = explode('.', $defaultPhpVersion))) > 2) {
11+
$defaultPhpVersion = "$parts[0].$parts[1]";
12+
}
13+
14+
return ask(' What PHP version to install? ', $defaultPhpVersion, ['5.6', '7.4', '8.0', '8.1', '8.2', '8.3']);
1015
});
1116

1217
desc('Installs PHP packages');

0 commit comments

Comments
 (0)