kfoobar / laravel-file-transfer
FTP and SFTP file transfer classes for Laravel.
v1.0.0
2026-04-01 21:23 UTC
Requires
- php: >=7.3
- illuminate/support: >=7.0
- phpseclib/phpseclib: ^3.0
README
A lightweight Laravel package for transferring files over FTP and SFTP. Wraps PHP's built-in FTP functions and phpseclib3 behind a unified interface.
Requirements
- PHP >= 7.3
- Laravel >= 7.0
Installation
composer require kfoobar/laravel-file-transfer
The service provider is registered automatically via Laravel's package auto-discovery.
Usage
FTP
use KFoobar\FileTransfer\Services\FTP; $ftp = new FTP( user: 'username', pass: 'password', host: 'ftp.example.com', port: 21, // optional, default: 21 ssl: false, // optional, default: false ); $ftp->connect(); // List files $files = $ftp->list('/remote/path'); // Download $ftp->download('/remote/path/file.txt', '/local/path/file.txt'); // Upload $ftp->upload('/local/path/file.txt', '/remote/path/file.txt'); // Delete $ftp->delete('/remote/path/file.txt'); $ftp->disconnect();
SFTP
use KFoobar\FileTransfer\Services\SFTP; $sftp = new SFTP( user: 'username', pass: 'password', host: 'sftp.example.com', port: 22, // optional, default: 22 ); $sftp->connect(); // List files $files = $sftp->list('/remote/path'); // Download $sftp->download('/remote/path/file.txt', '/local/path/file.txt'); // Upload $sftp->upload('/local/path/file.txt', '/remote/path/file.txt'); // Delete $sftp->delete('/remote/path/file.txt'); $sftp->disconnect();
Note: Named arguments in the examples above require PHP 8.0 or higher. On PHP 7.3–7.4, use positional arguments instead.
Contribution
Contributions are welcome! If you'd like to contribute to this project, please follow these steps:
- Fork the repository.
- Create a new branch for your feature or bugfix.
- Make your changes and ensure tests pass.
- Submit a pull request with a detailed description of your changes.
License
This package is open-source and released under the MIT License. See LICENSE for more information.