googleshokry / ftp-client

此包的最新版本(dev-main)没有可用的许可信息。

dev-main 2023-03-12 02:08 UTC

This package is auto-updated.

Last update: 2024-09-12 05:33:41 UTC


README

Laravel FTP 客户端(或任何使用 composer 的其他项目)

这个项目被命名为 LaravelFtp,因为我希望这个包遵守 Laravel 自身的规范,它们很棒且易于使用。

它还使用了集合包,文件作为集合返回,因此您可以使用 Laravel 的集合函数。

使用方法

安装

使用 composer 安装此包

composer require dennissmink/laravel-ftp dev-master

使用方法

创建新的 FTP 客户端如下

$ftp = ftp($host, $user, $pass, $optionalport);

然后,检查您的连接是否成功

if(!$ftp){
    // Connection failed
    return 'Error while connecting to the FTP server';
}

// Do your stuff

方法

通用文件功能

$ftp->all(); // Returns all the files of the users root files (Collection)
$ftp->all('folder'); // Returns all the files of the directory folder (Collection)

$ftp->get('filename.txt') // Returns the content of the file, can also be: get('directory/filename.txt')
$ftp->save('filename.txt', 'content file'); // Save file 'filename.txt' with content 'content file', returns content if success
$ftp->rename('oldname.txt', 'newname.txt'); // Renames file or directory

创建文件/目录

$ftp->createFile('filename.txt'); // Creates a file with the name 'filename.txt'
$ftp->createDirectory('directory name'); // Creates a directory 'directory name'

删除文件/目录

$ftp->deleteFile('filename.txt'); // Deletes a file with the name 'filename.txt'
$ftp->deleteDirectory('directory name'); // Removes a directory with the name 'directory name' (And its contents..)
$ftp->emptyDirectory('directory name'); // Emptys a directory but keeps the directory itself

链接

Packagist: https://packagist.org.cn/packages/dennissmink/laravel-ftp

ftp-client