From 263244798a01c57dc2c26db982189a7dc714e14e Mon Sep 17 00:00:00 2001 From: Fabian Fuelling Date: Wed, 8 Apr 2015 12:41:32 +0200 Subject: [PATCH 1/4] =?UTF-8?q?Wrap=20=C2=B4php=C2=B4=20command=20with=20?= =?UTF-8?q?=C2=B4exec=C2=B4=20to=20prevent=20detached=20process=20on=20e.g?= =?UTF-8?q?.=20debian=20after=20stopping=20the=20background=20task?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Task/Development/PhpServer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Task/Development/PhpServer.php b/src/Task/Development/PhpServer.php index cec2fe256..163eae530 100644 --- a/src/Task/Development/PhpServer.php +++ b/src/Task/Development/PhpServer.php @@ -29,7 +29,7 @@ class PhpServer extends Exec { protected $port; protected $host = '127.0.0.1'; - protected $command = 'php -S %s:%d '; + protected $command = 'exec php -S %s:%d '; public function __construct($port) { From 5fd7db6db194876259e29752f722dd86b30e4a04 Mon Sep 17 00:00:00 2001 From: Fabian Fuelling Date: Wed, 8 Apr 2015 14:12:48 +0200 Subject: [PATCH 2/4] Adjust PhpServer unit test (add "exec") --- tests/unit/PHPServerTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/unit/PHPServerTest.php b/tests/unit/PHPServerTest.php index ee7538bae..ae10f6702 100644 --- a/tests/unit/PHPServerTest.php +++ b/tests/unit/PHPServerTest.php @@ -38,7 +38,7 @@ public function testServerCommand() $this->taskServer('8000') ->dir('web') ->getCommand() - )->equals('php -S 127.0.0.1:8000 -t web'); + )->equals('exec php -S 127.0.0.1:8000 -t web'); } -} \ No newline at end of file +} From 9dd7ead90ef73f4ddb2aba8aee64adc74d94dd35 Mon Sep 17 00:00:00 2001 From: Fabian Fuelling Date: Thu, 9 Apr 2015 11:59:39 +0200 Subject: [PATCH 3/4] Check operating system and wrap `php` call only on "linux" environments --- src/Task/Development/PhpServer.php | 6 +++++- tests/unit/PHPServerTest.php | 9 ++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/Task/Development/PhpServer.php b/src/Task/Development/PhpServer.php index 163eae530..20a9706b8 100644 --- a/src/Task/Development/PhpServer.php +++ b/src/Task/Development/PhpServer.php @@ -29,11 +29,15 @@ class PhpServer extends Exec { protected $port; protected $host = '127.0.0.1'; - protected $command = 'exec php -S %s:%d '; + protected $command = 'php -S %s:%d '; public function __construct($port) { $this->port = $port; + + if (strtolower(PHP_OS) === 'linux') { + $this->command = 'exec php -S %s:%d'; + } } public function host($host) diff --git a/tests/unit/PHPServerTest.php b/tests/unit/PHPServerTest.php index ae10f6702..b63aeeda9 100644 --- a/tests/unit/PHPServerTest.php +++ b/tests/unit/PHPServerTest.php @@ -34,11 +34,18 @@ public function testServerRun() public function testServerCommand() { + if (strtolower(PHP_OS) === 'linux') { + $expectedCommand = 'exec php -S 127.0.0.1:8000 -t web'; + } else { + $expectedCommand = 'php -S 127.0.0.1:8000 -t web'; + } + verify( $this->taskServer('8000') + ->host('127.0.0.1') ->dir('web') ->getCommand() - )->equals('exec php -S 127.0.0.1:8000 -t web'); + )->equals($expectedCommand); } } From 615d4b4c901527b4477e1c606e93e131f2fc0ad3 Mon Sep 17 00:00:00 2001 From: Fabian Fuelling Date: Thu, 9 Apr 2015 12:06:37 +0200 Subject: [PATCH 4/4] Add trailing space to command to stay consistent --- src/Task/Development/PhpServer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Task/Development/PhpServer.php b/src/Task/Development/PhpServer.php index 20a9706b8..d33e2fece 100644 --- a/src/Task/Development/PhpServer.php +++ b/src/Task/Development/PhpServer.php @@ -36,7 +36,7 @@ public function __construct($port) $this->port = $port; if (strtolower(PHP_OS) === 'linux') { - $this->command = 'exec php -S %s:%d'; + $this->command = 'exec php -S %s:%d '; } }