LaravelCollective / remote

Remote SSH Access for the Laravel Framework
MIT License
276 stars 106 forks source link

Call to undefined function App\Http\Controllers\Admin\ssh2_connect() #75

Closed robertnicjoo closed 5 years ago

robertnicjoo commented 5 years ago

I just installed this package on L5.8 and I can't get use of it!

All I get is this error:

Call to undefined function App\Http\Controllers\Admin\ssh2_connect()

Controller

use SSH;

public function save(Request $request){
        $ip = $request->input('server_ip');
        $port = $request->input('server_port');
        $sshUser= $request->input('server_ssh_user');
        $sshPw = $request->input('server_ssh_password');

        $sshConnection = ssh2_connect($ip, $port);
        //rest of the code which doesn't execute as result of line above returns error

I have SSH2 installed on my system, yet no luck 01

What I try to do

I want connect to live server and download git repository in root folder there.

  1. I've followed this docs and my issue above is the result of it.
  2. My remote.php file in config folder in untouched as I didn't know what I should to set there (just thought it's worth to mention)

Any idea?

ryanhalley commented 5 years ago

Hi. I believe I am correct in saying you are on the wrong track. I'm sure you've resolved this, but I'll add my steps in case it helps someone else. Following the v5.8 docs instead, which are marginally simpler:

  1. Installed L5.8
  2. Use the matching laravelcollective/remote 5.8 docs (https://github.com/LaravelCollective/docs/blob/5.8/ssh.md) i.e the composer step, and the artisan step.
  3. In PhpStorm, pasted in the following, based on the examples in the docs :
     $commands = [
         'ls -la',
     ];
     SSH::run($commands, function($line)
     {
         echo $line.PHP_EOL;
     })
  4. Note: a) Hovering over 'SSH' showed 'Undefined class SSH' - nothing I did could resolve that, yet, when tested, works fine. I don't know if this is related to the L5.8 install, which someone else did b) I didn't add a 'use' or use \SSH because whichever I tried, made no difference to message.
  5. Finally, before testing, edited config/remote.php (as created by the artisan command), and in my case, set just 'host', 'username', and set 'key' to the location of my pem file (for Windows use this format with forward slashes: 'D:/private_key.pem'
  6. So, no need to enable any extensions in Laragon at all, and no need to try to configure connection outside of remote.php.