anchu/ftp
Composer 安装命令:
composer require anchu/ftp
包简介
A simple Laravel 7 ftp service provider
README 文档
README
A simple Laravel 5/6/7 ftp service provider.
For Laravel 4.x, check v1.0.0
Installation
Add the package to your composer.json and run composer update.
{
"require": {
"anchu/ftp": "~2.0"
}
}
If you're using Laravel 5.5+ skip the next step, as Laravel auto discover packages.
Add the service provider in config/app.php:
'Anchu\Ftp\FtpServiceProvider',
Configuration
Run php artisan vendor:publish --tag=config 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, 'secure' => 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.
anchu/ftp 适用场景与选型建议
anchu/ftp 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 584.44k 次下载、GitHub Stars 达 220, 最近一次更新时间为 2014 年 01 月 13 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「service provider」 「ftp」 「laravel」 「l5」 「l6」 「l7」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 anchu/ftp 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 anchu/ftp 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 anchu/ftp 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Time provider, providing consistent current date, time, datetime and timezone across the request.
An Zend Expressive module for loading ZF2 or ZF3 modules.
A sleek PHP wrapper around rclone with Laravel-style fluent API syntax
A fast and intuitive dependency injection container.
Registry service.
A remote FTP & S3 file manager using VueJS
统计信息
- 总下载量: 584.44k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 225
- 点击次数: 18
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2014-01-13