function ProcessFactory::create

Same name in this branch
  1. 11.x core/modules/package_manager/tests/modules/fixture_manipulator/src/ProcessFactory.php \Drupal\fixture_manipulator\ProcessFactory::create()

File

core/modules/package_manager/src/ProcessFactory.php, line 34

Class

ProcessFactory
Defines a process factory which sets the COMPOSER_HOME environment variable.

Namespace

Drupal\package_manager

Code

public function create(array $command, ?PathInterface $cwd = NULL, array $env = []) : ProcessInterface {
    $process = $this->decorated
        ->create($command, $cwd, $env);
    $env = $process->getEnv();
    if ($command && $this->isComposerCommand($command)) {
        $env['COMPOSER_HOME'] = $this->getComposerHomePath();
    }
    // Ensure that the current PHP installation is the first place that will be
    // searched when looking for the PHP interpreter.
    $env['PATH'] = static::getPhpDirectory() . ':' . getenv('PATH');
    $process->setEnv($env);
    return $process;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.