0

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"
Marcin Orlowski
  • 72,056
  • 11
  • 123
  • 141
pileup
  • 1
  • 2
  • 18
  • 45
  • 1
    What do you see when you run a `>set` from the terminal – RiggsFolly May 14 '23 at 16:22
  • I see a long list of variables, including the same `PATH` variables as seen above, which are taken from the System variables and not User variables. I tried adding `CHROME_PATH` again and running `set` but it won't show up there still – pileup May 14 '23 at 17:06
  • Update: When running the CMD as administrator I see the `CHROME_PATH` variable. I see now what might cause that. But not sure how to fix it, because I thought that if I set it in a System Variable it's visible to all users? – pileup May 14 '23 at 17:08
  • Update #2: Nope, my bad, `CHROME_PATH` now shows on both (admin and non-admin cmd) – pileup May 14 '23 at 17:14
  • Laravel just swallows `CHROME_PATH`! that is so weird – pileup May 14 '23 at 17:29
  • 1
    OP, you posted your question twice. Please to close one question and update the other with all the relevant information needed. There's no point for having two similar question posted. – Marcin Orlowski May 14 '23 at 18:49
  • Sorry because I thought one is related more to Windows and I wasn't sure if it's Laravel or the Windows system. Can I just remove the tags? so it will be 2 separate, one for the Windows part and one for Laravel because I am not sure what's the cause? – pileup May 14 '23 at 18:51
  • @MarcinOrlowski I deleted the other question – pileup May 14 '23 at 19:23
  • 1
    is there a max of 50 env vars? – Snapey May 14 '23 at 20:33
  • I don't think, because when I keep adding other variables than `CHROME_PATH` it shows them, only ignoring this one – pileup May 15 '23 at 02:33
  • 1
    Do you know how to use the PHP CLI? If so, run a simple `` Do you see the value from there? – RiggsFolly May 15 '23 at 10:07
  • omg, it shows the chrome path there! `[CHROME_PATH] => C:\Program Files (x86)\Microsoft\Edge\Application` (the path I gave it), but not on the Laravel project. What could cause that? – pileup May 15 '23 at 16:59

0 Answers0