I'm trying to handle the RunTimeException to connect with VPS through SSH.
Here's the Code to connect with VPS through SSH.
$server_ip = Input::get('server_ip');
$password = Input::get('password');
$validator = Validator::make(
['server_ip' => $server_ip],
['server_ip' => 'ip|required|unique:servers'],
['password' => $password],
['password' => 'required|confirmed']
);
if(!$validator->fails())
{
Config::set('remote.connections.production.host',$server_ip);
Config::set('remote.connections.production.username','root');
Config::set('remote.connections.production.password',$password);
Config::set('remote.connections.production.root','/');
$command = 'mysql --version';
$connection_status = SSH::run($command, function($line)
{
$this->output = $line.PHP_EOL;
});
if(!$connection_status)
return $this->output;
else
return view('dashboard.add_server');
}
else
return "Validation failed...";
It's Written in Laravel. In case, If I get error with SSH connection, It should redirect me to view named add_server. But, I'm getting Exception instead of redirection. Here's the Errror I get every time instead of Redirection.
What I want is, if there is some error connection to VPS through SSH, it should redirect me to view named add_server
Let me know what's wrong with code.
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1WS2rnX
via IFTTT
Aucun commentaire:
Enregistrer un commentaire