PHP code example of ourren / yii2-ssh2

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

    

ourren / yii2-ssh2 example snippets


use ourren\yii2ssh\Yii2ssh;
$yii_ssh = new Yii2ssh();
$host = "127.0.0.1";
$auth['username'] = 'root';
$auth['password'] = 'root';
if($yii_ssh->connect($host, $auth))
{
    $yii_ssh->run([
        'ls -al',
    ], function($line) {
        echo $line;
    });
}