hugsbrugs/php-sftp
Composer 安装命令:
composer require hugsbrugs/php-sftp
包简介
PHP SFTP Utilities
README 文档
README
PHP SFTP Utilities
If you also need FTP : php-ftp
Dependencies :
phpseclib : Github - Documentation - Examples
Install
Install package with composer
composer require hugsbrugs/php-sftp
In your PHP code, load librairy
require_once __DIR__ . '/vendor/autoload.php'; use Hug\Sftp\Sftp as Sftp;
Usage
Test SFTP connection
Sftp::test($server, $user, $password, $port = 22, $timeout = 10);
Check if a file exists on SFTP Server
Sftp::is_file($server, $user, $password, $remote_file, $port = 22, $timeout = 10);
Delete a file on remote FTP server
Sftp::delete($server, $user, $password, $remote_file, $port = 22, $timeout = 10);
Recursively deletes files and folder in given directory (If remote_path ends with a slash delete folder content otherwise delete folder itself)
Sftp::rmdir($server, $user, $password, $remote_path, $port = 22, $timeout = 10);
Recursively copy files and folders on remote SFTP server (If local_path ends with a slash upload folder content otherwise upload folder itself)
Sftp::upload_dir($server, $user, $password, $local_path, $remote_path, $port = 22, $timeout = 10);
Download a file from remote SFTP server
Sftp::download($server, $user, $password, $remote_file, $local_file, $port = 22, $timeout = 10);
Download a directory from remote FTP server (If remote_dir ends with a slash download folder content otherwise download folder itself)
Sftp::download_dir($server, $user, $password, $remote_dir, $local_dir, $port = 22, $timeout = 10);
Rename a file on remote SFTP server
Sftp::rename($server, $user, $password, $old_file, $new_file, $port = 22, $timeout = 10);
Create a directory on remote SFTP server
Sftp::mkdir($server, $user, $password, $directory, $port = 22, $timeout = 10);
Create a file on remote SFTP server
Sftp::touch($server, $user, $password, $remote_file, $content, $port = 22, $timeout = 10);
Upload a file on SFTP server
Sftp::upload($server, $user, $password, $local_file, $remote_file = '', $port = 22, $timeout = 10);
List files on SFTP server
Sftp::scandir($server, $user, $password, $path, $port = 22, $timeout = 10);
Get default login SFTP directory aka pwd
Sftp::pwd($server, $user, $password, $port = 22, $timeout = 10);
Tests
Edit example/test.php with your FTP parameters then run
php example/test.php
To Do
PHPUnit Tests
Author
Hugo Maugey visit my website ;)
hugsbrugs/php-sftp 适用场景与选型建议
hugsbrugs/php-sftp 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 151.73k 次下载、GitHub Stars 达 28, 最近一次更新时间为 2017 年 03 月 21 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 hugsbrugs/php-sftp 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 hugsbrugs/php-sftp 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 151.73k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 28
- 点击次数: 11
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: Unknown
- 更新时间: 2017-03-21