Skip to content

Commit 8589023

Browse files
committed
Using the command line to write log file instead of symfony process callback
1 parent bf18a6d commit 8589023

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/Extension/PhiremockProcess.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,10 @@ public function start($ip, $port, $path, $logsPath, $debug, $expectationsPath)
5151
{
5252
$phiremockPath = is_file($path) ? $path : $path . DIRECTORY_SEPARATOR . 'phiremock';
5353
$expectationsPath = is_dir($expectationsPath) ? $expectationsPath : '';
54-
55-
$this->initProcess($ip, $port, $debug, $expectationsPath, $phiremockPath);
56-
$this->logPhiremockCommand($debug);
5754
$logFile = $logsPath . DIRECTORY_SEPARATOR . self::LOG_FILE_NAME;
58-
$this->process->start(function ($type, $buffer) use ($logFile) {
59-
file_put_contents($logFile, $buffer, FILE_APPEND);
60-
});
55+
$this->initProcess($ip, $port, $debug, $expectationsPath, $phiremockPath, $logFile);
56+
$this->logPhiremockCommand($debug);
57+
$this->process->start();
6158
}
6259

6360
/**
@@ -74,8 +71,9 @@ public function stop()
7471
* @param bool $debug
7572
* @param string $expectationsPath
7673
* @param string $phiremockPath
74+
* @param string $logFile
7775
*/
78-
private function initProcess($ip, $port, $debug, $expectationsPath, $phiremockPath)
76+
private function initProcess($ip, $port, $debug, $expectationsPath, $phiremockPath, $logFile)
7977
{
8078
$commandline = [
8179
$this->getCommandPrefix() . $phiremockPath,
@@ -91,8 +89,10 @@ private function initProcess($ip, $port, $debug, $expectationsPath, $phiremockPa
9189
$commandline[] = '-e';
9290
$commandline[] = $expectationsPath;
9391
}
92+
$commandline[] = '>';
93+
$commandline[] = $logFile;
94+
$commandline[] = '2>&1';
9495

95-
// Process wraps the command with 'exec' in UNIX OSs.
9696
$this->process = new Process(implode(' ', $commandline));
9797
}
9898

@@ -119,6 +119,6 @@ private function getCommandPrefix()
119119
*/
120120
private function isWindows()
121121
{
122-
return PHP_OS === 'WIN32' || PHP_OS === 'WINNT' || PHP_OS === 'Windows';
122+
return DIRECTORY_SEPARATOR === '\\';
123123
}
124124
}

0 commit comments

Comments
 (0)