You are here

public function Process::setEnv in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/symfony/process/Process.php \Symfony\Component\Process\Process::setEnv()

Sets the environment variables.

An environment variable value should be a string. If it is an array, the variable is ignored.

That happens in PHP when 'argv' is registered into the $_ENV array for instance.

Parameters

array $env The new environment variables:

Return value

self The current Process instance

1 call to Process::setEnv()
Process::__construct in vendor/symfony/process/Process.php
Constructor.

File

vendor/symfony/process/Process.php, line 1024

Class

Process
Process is a thin wrapper around proc_* functions to easily start independent PHP processes.

Namespace

Symfony\Component\Process

Code

public function setEnv(array $env) {

  // Process can not handle env values that are arrays
  $env = array_filter($env, function ($value) {
    return !is_array($value);
  });
  $this->env = array();
  foreach ($env as $key => $value) {
    $this->env[$key] = (string) $value;
  }
  return $this;
}