PHP code example of azurre / php-shell

1. Go to this page and download the library: Download azurre/php-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/ */

    

azurre / php-shell example snippets


$loader = re\Component\System\Shell;

$cmd = 'ls -lwa /tmp';
echo Shell::create()->run($cmd);

$shell = new Shell;
$shell->runAsync('ping -c 5 127.0.0.1');

echo "Start background task\n";
while($shell->isProcessRunning()) {
    echo 'Working...' .PHP_EOL;
    sleep(1);
}
echo $shell;

$shell = new Shell;
$shell->run('ls /A/1/2/3/4')->waitForProcess();
if ($shell->getExitCode() !== Shell::NO_ERROR) {
    echo "\nExit code: {$shell->getExitCode()}\n";
    echo "Error: {$shell->getStdError()}\n";
} else {
    echo $shell->getStdOut();
}

curl -s https://getcomposer.org/installer | php

composer 

Exit code: 2
Error: ls: cannot access '/A/1/2/3/4': No such file or directory