Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This change allows a binary path to be given to the Process context, which in turn can be specified when constructing a WorkerProcess. The default worker factory now looks for an environment variable or constant named AMP_PHP_BINARY and, if found, uses the value for the PHP binary. Fixes #26 and supersedes #28.
- Loading branch information
Showing
3 changed files
with
12 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,10 +26,11 @@ class Process implements Context { | |
/** | ||
* @param string|array $script Path to PHP script or array with first element as path and following elements options | ||
* to the PHP script (e.g.: ['bin/worker', '-eOptionValue', '-nOptionValue']. | ||
* @param string $binary Path to PHP binary. Defaults to \PHP_BINARY. | ||
* @param string $cwd Working directory. | ||
* @param mixed[] $env Array of environment variables. | ||
*/ | ||
public function __construct($script, string $cwd = "", array $env = []) { | ||
public function __construct($script, string $binary = \PHP_BINARY, string $cwd = "", array $env = []) { | ||
$options = [ | ||
"html_errors" => "0", | ||
"display_errors" => "0", | ||
|
@@ -44,7 +45,7 @@ public function __construct($script, string $cwd = "", array $env = []) { | |
|
||
$options = (\PHP_SAPI === "phpdbg" ? " -b -qrr " : " ") . $this->formatOptions($options); | ||
$separator = \PHP_SAPI === "phpdbg" ? " -- " : " "; | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
trowski
Author
Member
|
||
$command = \escapeshellarg(\PHP_BINARY) . $options . $separator . $script; | ||
$command = \escapeshellarg($binary) . $options . $separator . $script; | ||
|
||
$processOptions = []; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
These options must be moved as well, otherwise it chooses the PHPDBG options if you run via PHPDBG, but have a
AMP_PHP_BINARY
specified.