I am trying to follow the guide of chrome-php/chrome
and add an environment variable called CHROME_PATH
but it doesn't detect it: https://github.com/chrome-php/chrome#using-different-chrome-executable.
When I dd($_SERVER);
it shows a list of all the variables, and I noticed it does take some variables from the system variables, however not all of them, and not the newly added CHROME_PATH
(after restarting the server and clearing cache).
I dd()
the $_SERVER
variable in the guessChromeBinaryPath()
method of chrome-php
:
public function guessChromeBinaryPath(): string
{
dd($_SERVER); // <-- here
if (\array_key_exists('CHROME_PATH', $_SERVER)) {
return $_SERVER['CHROME_PATH'];
}
switch (($this->osFamily)()) {
case 'Darwin':
return '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome';
case 'Windows':
return self::getFromRegistry() ?? '%ProgramFiles(x86)%\Google\Chrome\Application\chrome.exe';
default:
return null === self::shellExec('command -v google-chrome') ? 'chrome' : 'google-chrome';
}
}
Then it shows me a long list of certain variables, for example:
array:50 [▼ // vendor\chrome-php\chrome\src\AutoDiscover.php:33
"REDIRECT_MIBDIRS" => "C:/xampp/php/extras/mibs"
"REDIRECT_MYSQL_HOME" => "\xampp\mysql\bin"
"REDIRECT_PHP_PEAR_SYSCONF_DIR" => "\xampp\php"
"REDIRECT_PHPRC" => "\xampp\php"
"REDIRECT_TMP" => "\xampp\tmp"
"REDIRECT_STATUS" => "200"
"PHP_PEAR_SYSCONF_DIR" => "\xampp\php"
"PHPRC" => "\xampp\php"
"TMP" => "\xampp\tmp"
"HTTP_HOST" => "my_project.local"
"HTTP_CONNECTION" => "keep-alive"
"HTTP_CACHE_CONTROL" => "max-age=0"
"HTTP_UPGRADE_INSECURE_REQUESTS" => "1"
"HTTP_USER_AGENT" => "Mozilla/5.0 (Windows NT 10.0; Win64; x64)..."
"PATH" => "C:\WINDOWS\System32\OpenSSH\;C:\Program Files\Git\cmd;C:\ProgramData\ComposerSetup\bin;..."
The items in the "PATH"
key match the System variables (not User variables), but I added CHROME_PATH
to both just in case, and it still did not appear there.
But why?
Update: Very weird behavior: When I dd($_SERVER)
, it shows me all the env()
variables, except for CHROME_PATH
. When I add new variables it shows them being added to the dd()
. But when I use the key CHROME_PATH
it is being ignored! Just to make sure the value I put there is not the culprit, I actually replaced a working key with CHROME_PATH
and used the working value, but it disappeared(!):
// .env file
.. rest of the variables above ..
// adding new variables, including CHROME_PATH
"NEW_VAR1" => "TEST"
"NEW_VAR2" => "TEST"
"CHROME_PATH" => "TEST"
"NEW_VAR3" => "TEST"
And only CHROME_PATH
doesn't show in the output:
array:50 [▼ // vendor\chrome-php\chrome\src\AutoDiscover.php:33
"REDIRECT_MIBDIRS" => "C:/xampp/php/extras/mibs"
"REDIRECT_MYSQL_HOME" => "\xampp\mysql\bin"
"REDIRECT_PHP_PEAR_SYSCONF_DIR" => "\xampp\php"
"REDIRECT_PHPRC" => "\xampp\php"
"REDIRECT_TMP" => "\xampp\tmp"
"REDIRECT_STATUS" => "200"
"PHP_PEAR_SYSCONF_DIR" => "\xampp\php"
"PHPRC" => "\xampp\php"
"TMP" => "\xampp\tmp"
"HTTP_HOST" => "my_project.local"
"HTTP_CONNECTION" => "keep-alive"
"HTTP_CACHE_CONTROL" => "max-age=0"
"HTTP_UPGRADE_INSECURE_REQUESTS" => "1"
"HTTP_USER_AGENT" => "Mozilla/5.0 (Windows NT 10.0; Win64; x64)..."
"PATH" => "C:\WINDOWS\System32\OpenSSH\;C:\Program Files\Git\cmd;C:\ProgramData\ComposerSetup\bin;..."
"NEW_VAR1" => "TEST"
"NEW_VAR2" => "TEST"
"NEW_VAR3" => "TEST"