Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions
Driver Class Reference

Public Member Functions

 __construct (CommandRendererInterface $commandRenderer)
 
 execute ($command, $arguments)
 

Detailed Description

Shell driver encapsulates command execution and arguments escaping

Definition at line 14 of file Driver.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( CommandRendererInterface  $commandRenderer)
Parameters
CommandRendererInterface$commandRenderer

Definition at line 24 of file Driver.php.

25  {
26  $this->commandRenderer = $commandRenderer;
27  }

Member Function Documentation

◆ execute()

execute (   $command,
  $arguments 
)

Execute a command through the command line, passing properly escaped arguments, and return its output

Parameters
string$commandCommand with optional argument markers 's'
string[]$arguments Argument values to substitute markers with
Returns
Response
Exceptions
LocalizedException

Definition at line 37 of file Driver.php.

38  {
39  $disabled = explode(',', str_replace(' ', ',', ini_get('disable_functions')));
40  if (in_array('exec', $disabled)) {
41  throw new LocalizedException(new \Magento\Framework\Phrase('The exec function is disabled.'));
42  }
43 
44  $command = $this->commandRenderer->render($command, $arguments);
45  exec($command, $output, $exitCode);
46  $output = implode(PHP_EOL, $output);
47  return new Response(['output' => $output, 'exit_code' => $exitCode, 'escaped_command' => $command]);
48  }
exec($command, array &$output=null, &$return_var=null)
$arguments

The documentation for this class was generated from the following file: