PHP Class Jyxo\Shell\Client

Author: Ondřej Procházka
Author: Matěj Humpál
Datei anzeigen Open project: jyxo/php

Protected Properties

Property Type Description
$cwd string Actual working directory.
$env array Environment properties.
$error string Stderr output.
$out string Stdout output.
$processList array List of running processes.

Public Methods

Method Description
__construct ( string $cwd = '', array $env = [] ) Constructor.
clearEnv ( ) : Client Removes environment properties.
exec ( string $cmd, integer &$status = null ) : Client Executes an external command.
getError ( ) : string Returns stderr contents.
getOut ( ) : string Returns stdout contents.
killProcess ( string $name ) : self Kills all processes of the given name.
loadProcessList ( ) : self Returns a list of processes.
processExists ( string $name ) : boolean Checks if there is a process of the given name.
setCwd ( string $cwd = '' ) : Client Sets working directory.
setEnv ( array $env ) : Client Adds one or more environment properties.

Method Details

__construct() public method

Constructor.
public __construct ( string $cwd = '', array $env = [] )
$cwd string Working directory
$env array Array of environment properties

clearEnv() public method

Removes environment properties.
public clearEnv ( ) : Client
return Client

exec() public method

Captures stdout and stderr. Throws an exception on status code != 0.
public exec ( string $cmd, integer &$status = null ) : Client
$cmd string Command to execute
$status integer Status code
return Client

getError() public method

Returns stderr contents.
public getError ( ) : string
return string

getOut() public method

Returns stdout contents.
public getOut ( ) : string
return string

killProcess() public method

Works only on Linux.
public killProcess ( string $name ) : self
$name string Process name
return self

loadProcessList() public method

Works only on Linux.
public loadProcessList ( ) : self
return self

processExists() public method

Works only on Linux.
public processExists ( string $name ) : boolean
$name string Process name
return boolean

setCwd() public method

Defaults to null.
public setCwd ( string $cwd = '' ) : Client
$cwd string Working directory
return Client

setEnv() public method

Adds one or more environment properties.
public setEnv ( array $env ) : Client
$env array Array of properties
return Client

Property Details

$cwd protected_oe property

Actual working directory.
protected string $cwd
return string

$env protected_oe property

Environment properties.
protected array $env
return array

$error protected_oe property

Stderr output.
protected string $error
return string

$out protected_oe property

Stdout output.
protected string $out
return string

$processList protected_oe property

List of running processes.
protected array $processList
return array