@Snapey At first I thought I should add it to the system's environment variables (In Windows for example), but it didn't work so then I changed it to the bottom of the .env file.
Now I know it's not good to read directly from the .env on Laravel, but I just checked against other variables there. I added variables at the bottom of the .env, then dd()'d the $_SERVER in the piece of code above:
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';
}
}
It then showed me all the environment variables from the .env, except for the specific CHROME_PATH. It's like it's "deleting" it, for example I added the following to the bottom of the .env:
SOME_VAR1="VAL1"
CHROME_PATH="TEST"
SOME_VAR2="VAL2"
and the dd($_SERVER); output was:
"SOME_VAR1" => "VAL1"
"SOME_VAR2" => "VAL2"
completely ignoring CHROME_PATH (And CHROME_PATH only).
Now I will use your solution of reading from the config, but I'm just so curious, why it ignores specifically CHROME_PATH??
If I change it to : CHROME_PAT, it reads it:
// .env file:
SOME_VAR1="VAL1"
CHROME_PAT="TEST"
SOME_VAR2="VAL2"
the the dd($_SERVER) would be:
"SOME_VAR1" => "VAL1"
"CHROME_PAT" => "TEST"
"SOME_VAR2" => "VAL2"