PHP code example of decodelabs / systemic

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

    

decodelabs / systemic example snippets


use DecodeLabs\Systemic;

$dir = 'path/to/working-directory';

// Launch and capture output of a process
echo Systemic::capture(['ls', '-al'], $dir)->getOutput();

// Launch and capture output of a process with raw string command (not escaped)
echo Systemic::capture('ls -al', $dir)->getOutput();

// Launch and capture output of a script
echo Systemic::capture(['myPhpScript.php'], $dir)->getOutput();

// Launch a background task
$process = Systemic::launch(['make', 'install']);

// Launch a background script
$process = Systemic::launchScript(['myPhpScript.php'], $dir);

// Run a piped pseudo terminal process
$success = Systemic::run(['interactive-app', '--arg1'], $dir);

// Run a piped pseudo terminal script
$success = Systemic::runScript(['myPhpScript.php', '--arg1'], $dir);

// Custom escaped command
$success = Systemic::command(['escaped', 'arguments'])
    ->setWorkingDirectory($dir)
    ->addSignal('SIGSTOP') // Pass SIGSTOP through when caught
    ->setUser('someuser') // Attempt to use sudo to run as user
    ->run();

// Custom raw command with env arguments
$result = Systemic::command('echo ${:VARIABLE} | unescaped-command', [
        'VARIABLE' => 'Hello world'
    ])
    ->setWorkingDirectory($dir)
    ->capture();

use DecodeLabs\Systemic;

// OS info
echo Systemic::$os->getName(); // Linux | Windows | Darwin
echo Systemic::$os->getPlatformType(); // Unix | Windows
echo Systemic::$os->getDistribution(); // eg Ubuntu or High Sierra, etc
echo Systemic::$os->getVersion(); // System version info
echo Systemic::$os->getRelease(); // System version number
echo Systemic::$os->getHostName(); // System hostname

// Find binaries on the system
echo Systemic::$os->which('php'); // eg /usr/local/bin/php