trafficgate / transferer
处理文件传输的 PHP 对象。
v6.0.0
2023-08-29 06:13 UTC
Requires
- php: ^8.0
- illuminate/console: 8.*|9.*|10.*
- illuminate/support: 8.*|9.*|10.*
- trafficgate/shell-command: ~3.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ~3.0
- ocramius/package-versions: ^2.0
- orchestra/testbench: ~6.0|~7.0|~8.0
- phpunit/phpunit: ~9.0|~10.0
- symfony/process: ~5.0|~6.0
README
处理 rsync、scp 和基于 ssh 的文件传输的辅助 PHP 对象。
rsync
当前 rsync 的可用选项与 CentOS 6.x 上的 rsync 可用选项相匹配。
以下选项尚未实现
- 关闭带有
no-
前缀的选项 - 使用
remote-
前缀发送仅远程选项
完整文档可以在 RsyncTransfer 类中找到。
<?php use Trafficgate\Transferer\Transfer\RsyncTransfer; $rsync = new RsyncTransfer(); $rsync ->source($source, $host = null, $user = null) ->destination($destination, $host = null, $user = null) ->transfer($idleTimeout = null);
scp
当前 ssh 的可用选项与 CentOS 6.x 上的 rsync 可用选项相匹配。
完整文档可以在 ScpTransfer 类中找到。
<?php use Trafficgate\Transferer\Transfer\ScpTransfer; $scp = new ScpTransfer(); $scp ->source($source, $host = null, $user = null) ->destination($destination, $host = null, $user = null) ->transfer($idleTimeout = null);
ssh
SSH 实现非常原始。它很可能将来会转移到不同的软件包中,因为它不完全符合本软件包的目标。
它目前实现了以下选项
-
启用静默模式
$ssh->quietMode($enabled = true)
-
添加 SSH 配置选项
$ssh->configOptions($value, $remove = false, $enabled = true)
-
要连接的主机。如果它与执行 PHP 脚本的用户不同,则应包括
username@
$ssh->host($host)
-
通过 SSH 执行的命令
$ssh->remoteCommand($command)
命令默认启用静默模式,并包含以下 SSH 选项
BatchMode yes
StrictHostKeyChecking no
UserKnownHostsFile /dev/null
<?php use Trafficgate\Transferer\Ssh\SshCommand; $ssh = new SshCommand(); $ssh ->host($host) ->remoteCommand($command);