Skip to content

Commit d6b8b97

Browse files
authored
Merge pull request #1083 from MeMattStone/master
Added ability to use a `.valetphprc` file with `valet use` in a project to define the required PHP version
2 parents b377131 + 81b6b8f commit d6b8b97

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

cli/valet.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,18 @@
495495
*/
496496
$app->command('use [phpVersion] [--force]', function ($phpVersion, $force) {
497497
if (!$phpVersion) {
498-
return info('Valet is using ' . Brew::linkedPhp());
498+
$path = getcwd() . '/.valetphprc';
499+
$linkedVersion = Brew::linkedPhp();
500+
if (!file_exists($path)) {
501+
return info(sprintf('Valet is using %s.', $linkedVersion));
502+
}
503+
504+
$phpVersion = trim(file_get_contents($path));
505+
info('Found \'' . $path . '\' specifying version: ' . $phpVersion);
506+
507+
if ($linkedVersion == $phpVersion) {
508+
return info(sprintf('Valet is already using %s.', $linkedVersion));
509+
}
499510
}
500511

501512
PhpFpm::validateRequestedVersion($phpVersion);

0 commit comments

Comments
 (0)