PHP code example of legobox-co / quick-ssh
1. Go to this page and download the library: Download legobox-co/quick-ssh 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/ */
legobox-co / quick-ssh example snippets
...
return [
'providers' => [
...
Legobox\QuickSsh\SshServiceProvider::class,
...
],
'aliases' => [
...
'QuickSsh' => 'Legobox\QuickSsh\Facades\QuickSsh::class',
...
]
]
use QuickSsh;
$keys = QuickSsh::createKeys($value = null);
$keys->publicKey // return the public key
$keys->privateKey // return the private key
use QuickSsh;
// server options host, keytext, username
$serverInstance = QuickSsh::connector($serverOptions)->connect();
$serverInstance->run([
'cd /var/www',
'git pull origin master',
]);
$serverInstance->run($commands, function($line)
{
echo $line.PHP_EOL;
});
$serverInstance->define('deploy', [
'cd /var/www',
'git pull origin master',
'php artisan migrate',
]);
$serverInstance->task('deploy', function($line)
{
echo $line.PHP_EOL;
});
$serverInstance->get($remotePath, $localPath);
$contents = $serverInstance->getString($remotePath);
$serverInstance->put($localFile, $remotePath);
$serverInstance->putString($remotePath, 'Foo');
bash
$ php artisan vendor:publish --provider="Legobox\QuickSsh\SshServiceProvider"