jackyliu/ftp
Composer 安装命令:
composer require jackyliu/ftp
包简介
Wannabe successor of anchu/ftp package for Laravel
README 文档
README
A simple Laravel 8 ftp service provider.
For Laravel 8.x, check [v1.0.0]
Installation
Add the package to your composer.json and run composer update.
{
"require": {
"JackyLiu/ftp": "~1.0"
}
}
Add the service provider in config/app.php:
'JackyLiu\Ftp\FtpServiceProvider',
Configuration
Run php artisan vendor:publish and modify the config file(config/ftp.php) with your ftp connections.
You can add dynamic FTP connections with following syntax
Config::set('ftp.connections.key', array( 'host' => '', 'username' => '', 'password' => '', 'passive' => false, ));
Accessing connections
You can access default FTP connection via the FTP::connection method:
FTP::connection()->getDirListing(...);
When using multiple connections you can access each specific ftp connection by passing connection name:
FTP::connection('foo')->getDirListing(...);
Sometimes you may need to reconnect to a given ftp:
FTP::reconnect('foo');
If you need to disconnect from a given ftp use the disconnect method:
FTP::disconnect('foo');
Basic usage examples
// With custom connection $listing = FTP::connection('my-ftp-connection')->getDirListing(); // with default connection $listing = FTP::connection()->getDirListing(); $status = FTP::connection()->makeDir('directory-name');
Supported methods
getDirListing($directory, $parameters )
Returns a list of files in the given directory
$directory: The directory to be listed. Default value:..$parameters: Optional parameters to prefix with directory. For example:-la. Default:null.
getDirListingDetailed($directory)
Returns a list of files in the given directory as an associative array with the following keys: rights, number, user, group, size, month, day and time
$directory: The directory to be listed. Default value:..
makeDir($directory)
Creates the specified directory on the FTP server.
$directory: The name of the directory that will be created.
changeDir($directory)
Changes the current directory on a FTP server.
$directory: The target directory.
uploadFile($fileFrom, $fileTo, $mode)
Uploads a local file to the FTP server.
$fileFrom: The local file path.$fileTo: The remote file path.$mode: The transfer mode. Must be eitherFTP_ASCIIorFTP_BINARY. Automatic mode resolution will be done if no mode is specified.
downloadFile($fileFrom, $fileTo, $mode)
Downloads a file from the FTP server
$fileFrom: The remote file path.$fileTo: The local file path (will be overwritten if the file already exists) or an open file pointer in which we store the data.- .
$mode: The transfer mode. Must be eitherFTP_ASCIIorFTP_BINARY. Automatic mode resolution will be done if no mode is specified.
readFile($fileFrom)
Same as the downloadFile() method except it downloads the remote file to the PHP output buffer and returns it.
$fileFrom: The remote file path.
moveUp()
Changes to the parent directory.
permission($mode, $filename)
Set permissions on a file.
$mode: The new permissions, given as an octal value.$filename: The remote file.
delete($path)
Deletes the file specified by path from the FTP server.
$path: The file to delete.
currentDir()
Returns the current directory name
rename($oldName, $newName)
Renames a file or a directory on the FTP server.
$oldName: The old file/directory name.$newName: The new name.
removeDir($directory, $recursive)
Removes a directory
$directory: The directory to delete. This must be either an absolute or relative path to an empty directory.$recursive: Delete the folder recursively. Default value: false.
truncateDir($directory)
Truncates a directory
$directory: The directory to truncate. This must be either an absolute or relative path to a directory.
size($remoteFile)
Returns the size of the given file in bytes.
Note: Not all servers support this feature.
$remoteFile: The remote file.
time($remoteFile)
Returns the last modified time of the given file
Note: Not all servers support this feature.
$remoteFile: The remote file.
jackyliu/ftp 适用场景与选型建议
jackyliu/ftp 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 177 次下载、GitHub Stars 达 0, 最近一次更新时间为 2022 年 08 月 03 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 jackyliu/ftp 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 jackyliu/ftp 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 177
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 3
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-08-03