cullylarson/wp-deploy-folder-sync
Composer 安装命令:
composer require cullylarson/wp-deploy-folder-sync
包简介
Library for syncing Wordpress folders, like the uploads folder. Useful for deploying, or pulling changes.
关键字:
README 文档
README
A library for syncing Wordpress folders. Can be used as part of a deployment system. Useful for deploying or pulling resources like the 'uploads' folder, since it likely contains files that the site depends on.
This project is meant to be a composable component. It does one thing, sync
folders. If you want to do more, as part of a deployment system, then check
out the other projects in the Wordpress\Deploy namespace.
Dependencies
-
The
rsynclinux command is used to perform the sync. So, it must be available via the command-line. You'll get aRuntimeExceptionif you try to callFolderSync::syncwithout thersynccommand. -
All other dependencies are defined in
composer.json.
Install
curl -s http://getcomposer.org/installer | php
php composer.phar require cullylarson/wp-deploy-folder-sync
Usage
Everything is done through an instance of the Wordpress\Deploy\FolderSync
class.
Construction
The Wordpress\Deploy\FolderSync constructor takes three arguments:
- source The source folder. It must have a trailing slash (
/). - dest The destination folder. After the sync is run, the destination folder
will match the source folder. It must have a trailing slash (
/). - options A set of options, described below.
Source and Destination Paths
These paths provided in the source and dest params can be any paths that
the rsync command recognizes. So you can provide either remote or local
paths. For example:
username@example.com:path/to/source/
relative/path/to/destination/
/absolute/path/to/destination/
Options
The constructor accepts the following options:
-
delete boolean (Default: true) Whether to delete files when syncing (e.g. if a file no longer exists at the source, then delete it from the destination).
-
exclude array (Default: []) An array of patterns to exclude from the sync. See the rsync man page for details on --exclude.
Syncing
The sync is performed by calling the Wordpress\Deploy\FolderSync::sync function.
This will examine your source folder and dest folder, and will make any changes
necessary so that your dest folder ends up just like your source folder. In
this way, the folders will be synchronized.
Example
<?php
class MyWordpressDeployer {
public function deploy() {
// ...
$folderSync = new Wordpress\Deploy\FolderSync(
"path/to/local/uploads/",
"username@example.com:path/to/remote/uploads/",
['delete' => true, 'exclude' => ['.gitkeep']]);
$folderSync->sync();
// ...
}
}
Status Callback
The Wordpress\Deploy\FolderSync::sync function can optionally accept a callback
function. This callback will be called whenever the sync function wants to post
a status update (e.g. "I'm running", "Here's the output of the rsync command",
"Something went wrong", etc.). It allows you to have some control over whether
and how messages are handled.
The callback must take one parameter, an instance of Wordpress\Deploy\FolderSync\Status.
Here's an example:
<?php
class MyWordpressDeployer {
public function deploy() {
// ...
$statusCallback = function(Wordpress\Deploy\FolderSync\Status $status) {
echo $status->Timestamp . " -- ";
if( $status->isError() ) echo "ERROR: ";
if( $status->isWarning() ) echo "WARNING: ";
if( $status->isRawOutput() ) echo "================\n";
echo $status->Message;
if( $status->isRawOutput() ) echo "================\n";
}
$folderSync = new Wordpress\Deploy\FolderSync(
"path/to/local/uploads/",
"username@example.com:path/to/remote/uploads/");
$folderSync->sync($statusCallback);
// ...
}
}
cullylarson/wp-deploy-folder-sync 适用场景与选型建议
cullylarson/wp-deploy-folder-sync 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 42 次下载、GitHub Stars 达 1, 最近一次更新时间为 2015 年 08 月 31 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「deploy」 「wordpress」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 cullylarson/wp-deploy-folder-sync 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 cullylarson/wp-deploy-folder-sync 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 cullylarson/wp-deploy-folder-sync 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
blueways deployer recipes
The Laragoon utility package
A Highly Opinionated Symfony3/4 Deployer Recipe
Laravel Release Scripts, easy to set up one-off execute scripts that will be running during deploy script.
Deploy is an Artisan command with the aim to provide a very simple way to deploy your code into staging and production while ensuring valid version tags are applied.
Laravel package used to automatically deploy code from GIT version controls
统计信息
- 总下载量: 42
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 20
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-08-31