Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Process.php

function Process::fromShellCommandline

Creates a Process instance as a command-line to be run in a shell wrapper.

Command-lines are parsed by the shell of your OS (/bin/sh on Unix-like, cmd.exe on Windows.) This allows using e.g. pipes or conditional execution. In this mode, signals are sent to the shell wrapper and not to your commands.

In order to inject dynamic values into command-lines, we strongly recommend using placeholders. This will save escaping values, which is not portable nor secure anyway:

$process = Process::fromShellCommandline('my_command "${:MY_VAR}"'); $process->run(null, ['MY_VAR' => $theValue]);

Parameters

string $command The command line to pass to the shell of the OS:

string|null $cwd The working directory or null to use the working dir of the current PHP process:

array|null $env The environment variables or null to use the same environment as the current PHP process:

mixed $input The input as stream resource, scalar or \Traversable, or null for no input:

int|float|null $timeout The timeout in seconds or null to disable:

Throws

LogicException When proc_open is not installed

4 calls to Process::fromShellCommandline()
GenerateTheme::getStarterKitVersion in core/lib/Drupal/Core/Command/GenerateTheme.php
Perforce::windowsLogin in vendor/composer/composer/src/Composer/Util/Perforce.php
ProcessExecutor::runProcess in vendor/composer/composer/src/Composer/Util/ProcessExecutor.php
ProcessExecutor::startJob in vendor/composer/composer/src/Composer/Util/ProcessExecutor.php
2 methods override Process::fromShellCommandline()
PhpProcess::fromShellCommandline in vendor/symfony/process/PhpProcess.php
Creates a Process instance as a command-line to be run in a shell wrapper.
PhpSubprocess::fromShellCommandline in vendor/symfony/process/PhpSubprocess.php
Creates a Process instance as a command-line to be run in a shell wrapper.

File

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

Class

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

Namespace

Symfony\Component\Process

Code

public static function fromShellCommandline(string $command, ?string $cwd = null, ?array $env = null, mixed $input = null, ?float $timeout = 60) : static {
    $process = new static([], $cwd, $env, $input, $timeout);
    $process->commandline = $command;
    return $process;
}
RSS feed
Powered by Drupal