From 77cd98f4ccf868e2a4a870bb09e26695f468f574 Mon Sep 17 00:00:00 2001 From: Chris Brown Date: Thu, 28 Jul 2016 12:20:37 -0400 Subject: [PATCH] Add basic changes to alllow php71 --- cli/Valet/Brew.php | 7 +++++-- cli/Valet/PhpFpm.php | 9 ++++++--- tests/BrewTest.php | 5 ++++- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/cli/Valet/Brew.php b/cli/Valet/Brew.php index 79c1eda7c..dbfc6912f 100644 --- a/cli/Valet/Brew.php +++ b/cli/Valet/Brew.php @@ -40,7 +40,8 @@ function installed($formula) */ function hasInstalledPhp() { - return $this->installed('php70') + return $this->installed('php71') + || $this->installed('php70') || $this->installed('php56') || $this->installed('php55'); } @@ -137,7 +138,9 @@ function linkedPhp() $resolvedPath = $this->files->readLink('/usr/local/bin/php'); - if (strpos($resolvedPath, 'php70') !== false) { + if (strpos($resolvedPath, 'php71') !== false) { + return 'php71'; + } elseif (strpos($resolvedPath, 'php70') !== false) { return 'php70'; } elseif (strpos($resolvedPath, 'php56') !== false) { return 'php56'; diff --git a/cli/Valet/PhpFpm.php b/cli/Valet/PhpFpm.php index 727c0a290..62ea8b4e0 100644 --- a/cli/Valet/PhpFpm.php +++ b/cli/Valet/PhpFpm.php @@ -36,7 +36,8 @@ public function __construct(Brew $brew, CommandLine $cli, Filesystem $files) */ public function install() { - if (! $this->brew->installed('php70') && + if (! $this->brew->installed('php71') && + ! $this->brew->installed('php70') && ! $this->brew->installed('php56') && ! $this->brew->installed('php55')) { $this->brew->ensureInstalled('php70', $this->taps); @@ -83,7 +84,7 @@ public function restart() */ public function stop() { - $this->brew->stopService('php55', 'php56', 'php70'); + $this->brew->stopService('php55', 'php56', 'php70', 'php71'); } /** @@ -93,7 +94,9 @@ public function stop() */ public function fpmConfigPath() { - if ($this->brew->linkedPhp() === 'php70') { + if ($this->brew->linkedPhp() === 'php71') { + return '/usr/local/etc/php/7.1/php-fpm.d/www.conf'; + } elseif ($this->brew->linkedPhp() === 'php70') { return '/usr/local/etc/php/7.0/php-fpm.d/www.conf'; } elseif ($this->brew->linkedPhp() === 'php56') { return '/usr/local/etc/php/5.6/php-fpm.conf'; diff --git a/tests/BrewTest.php b/tests/BrewTest.php index af5228d81..3e6a2429f 100644 --- a/tests/BrewTest.php +++ b/tests/BrewTest.php @@ -66,18 +66,21 @@ public function test_installed_returns_false_when_given_formula_is_not_installed public function test_has_installed_php_indicates_if_php_is_installed_via_brew() { $brew = Mockery::mock(Brew::class.'[installed]', [new CommandLine, new Filesystem]); - $brew->shouldReceive('installed')->once()->with('php70')->andReturn(true); + $brew->shouldReceive('installed')->once()->with('php71')->andReturn(true); + $brew->shouldReceive('installed')->with('php70')->andReturn(true); $brew->shouldReceive('installed')->with('php56')->andReturn(true); $brew->shouldReceive('installed')->with('php55')->andReturn(true); $this->assertTrue($brew->hasInstalledPhp()); $brew = Mockery::mock(Brew::class.'[installed]', [new CommandLine, new Filesystem]); $brew->shouldReceive('installed')->once()->with('php70')->andReturn(true); + $brew->shouldReceive('installed')->with('php71')->andReturn(false); $brew->shouldReceive('installed')->with('php56')->andReturn(false); $brew->shouldReceive('installed')->with('php55')->andReturn(false); $this->assertTrue($brew->hasInstalledPhp()); $brew = Mockery::mock(Brew::class.'[installed]', [new CommandLine, new Filesystem]); + $brew->shouldReceive('installed')->once()->with('php71')->andReturn(false); $brew->shouldReceive('installed')->once()->with('php70')->andReturn(false); $brew->shouldReceive('installed')->once()->with('php56')->andReturn(false); $brew->shouldReceive('installed')->once()->with('php55')->andReturn(false);