PHP code example of bakhari / console

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

    

bakhari / console example snippets




use Bakhari\Console\Console;
use Bakhari\Console\Command;
use Bakhari\Console\Streams\FileOutputStream;

use PhanAn\Remote\Remote;
use Illuminate\Config\Repository as ConsoleConfig;

$console = new Console(new ConsoleConfig([
    'host'          => '127.0.0.1',
    'port'          => 22,
    'username'      => '<username>',
    'password'      => base64_decode('PHBhc3N3b3JkPg=='),
    'auto_login'    => false,
    'prompt'        => '/[\$>]/',
    'stdout'        => false,
]));

$console->pushOutputStream(new FileOutputStream('/tmp/console'));

$console->login();

$console->run(new Command([
    'hostname',
    'cat /etc/passwd',
]));