PHP code example of nulvem / remote

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

    

nulvem / remote example snippets


[
    'auth' => [
        'key_path' => env('REMOTE_KEY_PATH', storage_path('id_rsa')),
    ],
];

[
    'channels' => [
        'remote' => [
            'driver' => 'daily',
            'path' => storage_path('logs/remote.log'),
            'level' => env('LOG_LEVEL', 'debug'),
            'days' => 14,
        ],
    ],
]

use Nulvem\Remote\Facades\Remote;

$remote = Remote::ssh(host: '0.0.0.0');

$remote->run(script: 'hello-world');

use Nulvem\Remote\Facades\Remote;

$remote = Remote::ssh(
    host: '0.0.0.0',
    port: 2000
);

$remote->run(script: 'hello-world');

use Nulvem\Remote\Facades\Remote;

$remote = Remote::ssh(
    host: '0.0.0.0',
    timeout: 20
);

$remote->run(script: 'hello-world');

$remote = Remote::ssh(host: '0.0.0.0');

$remote->run(
    script: 'hello-world',
    data: [
        'name' => 'John Doe',
        'dir' => '/var/www/html'
    ]
)

use Nulvem\Remote\Facades\Remote;

$remote = Remote::ssh(host: '0.0.0.0');

$remote->run(script: 'install-server');

someLogic();

$remote->run(script: 'configure-server');

$remote = Remote::ssh(host: '0.0.0.0');

$execution = $remote->run(script: 'hello-world');

$execution->output();

$execution->success();

$execution->failed();

use Nulvem\Remote\Facades\Remote;

$remote = Remote::sftp(host: '0.0.0.0');

$remote->get(
    from: '/root/sample.json',
    to: storage_path('sample.json')
);

use Nulvem\Remote\Facades\Remote;

$remote = Remote::sftp(host: '0.0.0.0');

$remote->put(from: storage_path('sample.json'));

use Nulvem\Remote\Facades\Remote;

$remote = Remote::sftp(host: '0.0.0.0');

$remote->put(
    from: storage_path('sample.json'),
    to: '/var/www/html'
);

use Nulvem\Remote\Facades\Remote;

$remote = Remote::sftp(host: '0.0.0.0');

$remote->get(
    from: '/root/sample.json',
    to: storage_path('sample.json')
);

someLogicToChangeSampleFile();

$remote->put(from: storage_path('sample.json'));

$remote = Remote::ssh(host: '0.0.0.0');

$execution = $remote->put(from: storage_path('sample.json'));

$execution->success();

$execution->failed();
dotenv
REMOTE_LOG_CHANNEL=remote
bash
echo "Remote script 'install' started"

echo "Hello, my name is {{ $name }}!"
echo "I will list for you the files in the {{ $dir }} directory..."
pwd

echo "Remote script 'install' finished"