coercive / sftp
Coercive SFTP
0.0.0
2023-04-24 17:04 UTC
Requires
- php: >=7.4
- ext-ssh2: *
README
SFTP utility for PHP
Get
composer require coercive/sftp
Dependencies
This package use ext-ssh2
: manual
Usage
Connect to FTP
use Coercive\Utility\SFTP\SFTP; $SFtp = new SFTP('127.0 0.1', 22); $SFtp->login('BestUser', 'BestPassword'); $SFtp->connect();
Disconnect
$SFtp->disconnect();
Create directory
$SFtp->mkdir('/example/dir/test');
List diretories and files
$data = $SFtp->list('/example/dir/test');
Upload file
$SFtp->upload('/README.md', '/example/dir/test/test.md');
Download file
$SFtp->download('/example/dir/test/test.md', '/test/dowloaded_file.md');
Download file : with auto tmp name and prefix
$SFtp->setTmpPrefix('_test_tmp_prefix_'); $SFtp->download('/example/dir/test/test.md', $filepath); # do something with your file rename($filepath, '/test/dowloaded_file.md');
Filesize
$integer = $SFtp->filesize('/example/dir/test/test.md');
Read file
$data = $SFtp->read('/example/dir/test/test.md');
Write into file
$SFtp->write('/example/dir/test/test.md', "# Hello World !\n");
Remove file
$SFtp->delete('/example/dir/test/test.md');