jenwachter/php-rsync
Composer 安装命令:
composer require jenwachter/php-rsync
包简介
README 文档
README
A simple rsync library for PHP, able to perform local, remote, and Akamai NetStorage syncs. Note that this library is not all-inclusive of everything that can be done with the rsync command.
Requirements
- PHP >= 8.0
Installation
To install the library, you will need to use Composer in your project.
composer require jenwachter/php-rsync
Usage
Create a connection
To start using the library, you must first create a connection. This connection is then passed to the Rsync class.
$connection = new PhpRsync\Connection($type); $rsync = new Rsync($connection);
There are three types of connections:
Local
Use this type of connection when the source and destination are on the same machine. Example: transferring files from one directory to another on your local machine.
$local = new PhpRsync\Connection( 'local', '/path/to/destination/root/dir' ); $rsync = new Rsync($local);
Remote
Use this type of connection when the source and destination are different machines. Example: transferring files from your local machine to a remote machine.
$remote = new PhpRsync\Connection( 'remote', '/path/to/destination/root/dir', 'remote.host.com', 'username', ['ssh_key' => '/path/to/ssh/key'] ); $rsync = new Rsync($remote);
Alternatively, you can use a password for authentication by passing ['password' => 'your_password'] as the fifth parameter.
Akamai
Use this type of connection when the destination is Akamai NetStorage. For details on how to connect to NetStorage, see the NetStorage Rsync documentation
$akamai = new PhpRsync\Connection( 'akamai', '/path/to/destination/root/dir', 'cpcode.rsync.upload.akamai.com', 'username', ['ssh_key' => '/path/to/ssh/key'] ); $rsync = new Rsync($akamai);
Perform rsync transfers
$options = []; $rsync->run( '/path/to/source/dir', 'relative/path/to/destination/dir', $options );
Available options
- archive: Boolean. Adds
--archiveflag, if true. Default: true - compress: Boolean. Adds
--compressflag, if true. Default: true - cwd: String. Changes the current working directory prior to running the
rsynccommand. Default: null - delete: Boolean. Adds
--deleteflag, if true. Default: false - dryrun: Boolean. Adds
--dry-runand--verboseflags, if true. Default: false - exclude: Array|String. If a string is passed, adds
--exclude="<string>"flag. if an array of strings is passed, adds multiple--exclude="<string>"flags. Default: null - include: Array|String. If a string is passed, adds
--include="<string>"flag. if an array of strings is passed, adds multiple--include="<string>"flags. Default: null - relative: Boolean. Adds
--relativeflag, if true. Default: false
jenwachter/php-rsync 适用场景与选型建议
jenwachter/php-rsync 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 3.79k 次下载、GitHub Stars 达 2, 最近一次更新时间为 2023 年 09 月 14 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 jenwachter/php-rsync 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 jenwachter/php-rsync 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 3.79k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 17
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-09-14