lodev09 / php-ssh2
Wrapper class for PHP's SSH2 extension.
1.1.0
2022-02-16 18:31 UTC
Requires
- php: >=5.4
Requires (Dev)
None
Suggests
None
Provides
None
Conflicts
None
Replaces
None
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 fileSFTP::rm- delete remote fileSFTP::list- list remote filesSFTP::is_dir- check if path is a directorySFTP::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
- Jamie Munro
- Jovanni Lo @lodev09
License
Released under the MIT License. See LICENSE file.