coercive / sftp
Coercive SFTP
Installs: 4
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/coercive/sftp
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');