In case if you get:
Warning: ssh2_scp_recv(): Unable to receive remote file in /some-php-file.php on line 2
Use `stream_get_contents` function.
Example:
<?php
$stream = @fopen("ssh2.sftp://$sftp$remoteFile", 'r');
if (! $stream) {
throw new \Exception("Could not open file: $remoteFile");
}
$contents = stream_get_contents($stream);
file_put_contents ($localFile, $contents);
@fclose($stream);
?>