kfoobar/laravel-file-transfer

FTP and SFTP file transfer classes for Laravel.

Maintainers

Package info

github.com/KFoobar/laravel-file-transfer

pkg:composer/kfoobar/laravel-file-transfer

Statistics

Installs: 0

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v1.0.0 2026-04-01 21:23 UTC

This package is not auto-updated.

Last update: 2026-04-02 03:40:49 UTC


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:

  1. Fork the repository.
  2. Create a new branch for your feature or bugfix.
  3. Make your changes and ensure tests pass.
  4. 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.