lodev09/php-ssh2

Wrapper class for PHP's SSH2 extension.

1.1.0 2022-02-16 18:31 UTC

This package is auto-updated.

Last update: 2024-04-16 23:06:10 UTC


README

Wrapper class for PHP's SSH2 extension. The base class was created by Jamie Munro taken from this article.

Installation

$ composer require lodev09/php-ssh2

Usage

// connect
$auth = new \SSH2\Password(SFTP_USER, SFTP_PASSWORD);
$sftp = new \SSH2\SFTP(SFTP_HOST, $auth);

if ($sftp->is_connected() && $sftp->is_authenticated()) {
    // upload
    $sftp->put('/path/to/my/local/file', '/remote/file');

    // download
    $sftp->get('/remote/file', '/local/destination/file');
}

SFTP

Common helper methods includes:

  • SFTP::mv - move remote file
  • SFTP::rm - delete remote file
  • SFTP::list - list remote files
  • SFTP::is_dir - check if path is a directory
  • SFTP::exists - check if path exists

Other native methods can be called as well for example:

// ssh2_sftp_mkdir
$sftp->mkdir(...);

SCP

Just a pure wrapper of the native ssh2_scp_xxx functions.

// ssh2_scp_recv
$scp->recv(...);

Feedback

All bugs, feature requests, pull requests, feedback, etc., are welcome. Visit my site at www.lodev09.com or email me at lodev09@gmail.com

Credits

License

Released under the MIT License. See LICENSE file.