Skip to content

Instantly share code, notes, and snippets.

@cjmellor
Created August 20, 2016 22:58
Show Gist options
  • Save cjmellor/9bfbd56fe675fe7dc9297c2a25b70710 to your computer and use it in GitHub Desktop.
Save cjmellor/9bfbd56fe675fe7dc9297c2a25b70710 to your computer and use it in GitHub Desktop.
Some helpers for the SSH Remote Collective for Laravel.
<?php
/**
* Run a command on an environment through SSH
*
* @param array $commands
* @param bool $into
* @param string|null $env
* @return mixed
*/
function ssh(array $commands, bool $into = false, string $env = null)
{
if ($into) {
return SSH::into($env)->run($commands);
}
return SSH::run($commands);
}
/**
* Run a command and return the output through SSH.
*
* @param array $commands
* @return mixed
*/
function ssh_live(array $commands)
{
return SSH::run($commands, function ($line) {
echo $line.PHP_EOL;
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment