From f8c868ffc77a1defbb5ccc9cf68b124546f3ab04 Mon Sep 17 00:00:00 2001 From: Alex Rock Ancelet Date: Fri, 6 Jul 2018 17:56:04 +0200 Subject: [PATCH 1/2] Allow using an env var to determine chrome driver binary --- src/ProcessManager/ChromeManager.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/ProcessManager/ChromeManager.php b/src/ProcessManager/ChromeManager.php index b6b3e758..15a614d9 100644 --- a/src/ProcessManager/ChromeManager.php +++ b/src/ProcessManager/ChromeManager.php @@ -32,7 +32,7 @@ final class ChromeManager implements BrowserManagerInterface public function __construct(?string $chromeDriverBinary = null, ?array $arguments = null, array $options = []) { - $this->process = new Process([$chromeDriverBinary ?? $this->findChromeDriverBinary()], null, null, null, null); + $this->process = new Process([$chromeDriverBinary ?: $this->findChromeDriverBinary()], null, null, null, null); $this->arguments = $arguments ?? $this->getDefaultArguments(); $this->options = \array_merge($this->getDefaultOptions(), $options); } @@ -66,6 +66,10 @@ public function quit(): void private function findChromeDriverBinary(): string { + if ($binary = $_SERVER['PANTHERE_CHROME_DRIVER_BINARY'] ?? null) { + return $binary; + } + switch (PHP_OS_FAMILY) { case 'Windows': return __DIR__.'/../../chromedriver-bin/chromedriver.exe'; From b2d85d4bcc69f745e35a03b24a5a38e6d68ba6ae Mon Sep 17 00:00:00 2001 From: Alex Rock Ancelet Date: Wed, 11 Jul 2018 15:46:52 +0200 Subject: [PATCH 2/2] Added small documentation to use the PANTHERE_CHROME_DRIVER_BINARY env var --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 7d065078..bb089f9a 100644 --- a/README.md +++ b/README.md @@ -145,6 +145,7 @@ The following environment variables can be set to change some Panthère behavior * `PANTHERE_NO_HEADLESS`: to disable browsers's headless mode (will display the testing window, useful to debug) * `PANTHERE_NO_SANDBOX`: to disable [Chrome's sandboxing](https://chromium.googlesource.com/chromium/src/+/b4730a0c2773d8f6728946013eb812c6d3975bec/docs/design/sandbox.md) (unsafe, but allows to use Panthère in containers) * `PANTHERE_WEB_SERVER_DIR`: to change the project's document root (default to `public/`) +* `PANTHERE_CHROME_DRIVER_BINARY`: to use another `chromedriver` binary, instead of relying on the ones already provided by Panthère ## Docker Integration