PHP code example of iperamuna / laravel-remote-commands
1. Go to this page and download the library: Download iperamuna/laravel-remote-commands 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/ */
iperamuna / laravel-remote-commands example snippets
'servers' => [
'production' => [
'host' => '1.2.3.4',
'port' => 22,
'username' => 'deploy',
'auth_type' => 'key', // 'password' or 'key'
'password' => '',
'key' => '/path/to/id_rsa', // Path to public / private key file
'keytext' => '', // OR direct content of public / private key
'passphrase' => '', // Optional key passphrase
],
],
use LaravelRemoteCommands\Facades\RemoteCommand;
// Run commands and get output as an array
$output = RemoteCommand::into('production')->run([
'cd /var/www/html',
'ls -la',
]);
foreach ($output as $line) {
echo $line . PHP_EOL;
}
// Or stream output via callback
RemoteCommand::into('production')->run([
'git pull origin main',
], function($line) {
Log::info("Deployment: " . $line);
});