PHP code example of ghostwriter / shell

1. Go to this page and download the library: Download ghostwriter/shell library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

ghostwriter / shell example snippets


$shell = Shell::new();

$shell->execute('cd', [sys_get_temp_dir()]);

$result = $shell->execute(PHP_BINARY, ['-r', 'echo "#BlackLivesMatter";']);

$exitCode = $result->exitCode(); // 0
if ($exitCode !== 0) {
    throw new RuntimeException($result->stderr());
}

if ($exitCode === 0) {
    echo $result->stdout(); // "#BlackLivesMatter"
}