dennissmink/laravel-ftp

该包的最新版本(1.0.75)没有提供许可信息。

1.0.75 2017-09-14 09:55 UTC

This package is auto-updated.

Last update: 2024-08-28 09:08:55 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