Свойство | Тип | Описание | |
---|---|---|---|
$captureStdErr | whether to capture stderr (2>&1) when useExec is true. This will try to redirect the stderr to stdout and provide the complete output of both in getStdErr() and getError(). Default is true. | ||
$escapeArgs | whether to escape any argument passed through addArg(). Default is true. | ||
$escapeCommand | whether to escape the command passed to setCommand() or the constructor. This is only useful if $escapeArgs is false. Default is false. | ||
$locale | the locale to temporarily set before calling escapeshellargs(). Default is null for none. | ||
$procCwd | the initial working dir for proc_open(). Default is null for current PHP working dir. | ||
$procEnv | an array with environment variables to pass to proc_open(). Default is null for none. | ||
$procOptions | an array of other_options for proc_open(). Default is null for none. | ||
$useExec | whether to use exec() instead of proc_open(). This can be used on Windows system to workaround some quirks there. Note, that any errors from your command will be output directly to the PHP output stream. getStdErr() will also not work anymore and thus you also won't get the error output from getError() in this case. You also can't pass any environment variables to the command if this is enabled. Default is false. |
Свойство | Тип | Описание | |
---|---|---|---|
$_args | the list of command arguments | ||
$_command | the command to execute | ||
$_error | the error message | ||
$_execCommand | the full command string to execute | ||
$_executed | whether the command was successfully executed | ||
$_exitCode | the exit code | ||
$_stdErr | the stderr output | ||
$_stdOut | the stdout output |
Метод | Описание | |
---|---|---|
__construct ( string | array $options = null ) | ||
__toString ( ) : string | ||
addArg ( string $key, string | array | null $value = null, boolean | null $escape = null ) : static | ||
execute ( ) : boolean | Execute the command | |
getArgs ( ) : string | ||
getCommand ( ) : string | null | ||
getError ( boolean $trim = true ) : string | ||
getExecCommand ( ) : string | boolean | ||
getExecuted ( ) : string | ||
getExitCode ( ) : integer | null | ||
getIsWindows ( ) : boolean | ||
getOutput ( boolean $trim = true ) : string | ||
getStdErr ( boolean $trim = true ) : string | ||
setArgs ( string $args ) : static | ||
setCommand ( string $command ) : static | ||
setOptions ( array $options ) : static |
public __construct ( string | array $options = null ) | ||
$options | string | array | either a command string or an options array (see setOptions()) |
public __toString ( ) : string | ||
Результат | string | the current command string to execute |
public addArg ( string $key, string | array | null $value = null, boolean | null $escape = null ) : static | ||
$key | string | the argument key to add e.g. `--feature` or `--name=`. If the key does not end with and `=`, the $value will be separated by a space, if any. Keys are not escaped unless $value is null and $escape is `true`. |
$value | string | array | null | the optional argument value which will get escaped if $escapeArgs is true. An array can be passed to add more than one value for a key, e.g. `addArg('--exclude', array('val1','val2'))` which will create the option `--exclude 'val1' 'val2'`. |
$escape | boolean | null | if set, this overrides the $escapeArgs setting and enforces escaping/no escaping |
Результат | static | for method chaining |
public getCommand ( ) : string | null | ||
Результат | string | null | the command that was set through setCommand() or passed to the constructor. Null if none. |
public getExecCommand ( ) : string | boolean | ||
Результат | string | boolean | the full command string to execute. If no command was set with setCommand() or passed to the constructor it will return false. |
public getExecuted ( ) : string | ||
Результат | string | whether the command was successfully executed |
public getExitCode ( ) : integer | null | ||
Результат | integer | null | the exit code or null if command was not executed yet |
public getIsWindows ( ) : boolean | ||
Результат | boolean | whether we are on a Windows OS |
public setCommand ( string $command ) : static | ||
$command | string | the command or full command string to execute, like 'gzip' or 'gzip -d'. You can still call addArg() to add more arguments to the command. If $escapeCommand was set to true, the command gets escaped through escapeshellcmd(). |
Результат | static | for method chaining |
public setOptions ( array $options ) : static | ||
$options | array | array of name => value options that should be applied to the object You can also pass options that use a setter, e.g. you can pass a `fileName` option which will be passed to `setFileName()`. |
Результат | static | for method chaining |
public $captureStdErr |
public $escapeArgs |
public $escapeCommand |
public $locale |
public $procCwd |
public $procEnv |
public $procOptions |
public $useExec |