PHPackages                             cullylarson/wp-deploy-folder-sync - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [DevOps &amp; Deployment](/categories/devops)
4. /
5. cullylarson/wp-deploy-folder-sync

ActiveLibrary[DevOps &amp; Deployment](/categories/devops)

cullylarson/wp-deploy-folder-sync
=================================

Library for syncing Wordpress folders, like the uploads folder. Useful for deploying, or pulling changes.

v1.0.1(10y ago)1421MITPHPPHP &gt;=5.3.0

Since Aug 31Pushed 10y ago1 watchersCompare

[ Source](https://github.com/cullylarson/wp-deploy-folder-sync)[ Packagist](https://packagist.org/packages/cullylarson/wp-deploy-folder-sync)[ Docs](https://github.com/cullylarson/wp-deploy-folder-sync)[ RSS](/packages/cullylarson-wp-deploy-folder-sync/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)Dependencies (1)Versions (3)Used By (1)

Wordpress Deploy FolderSync
===========================

[](#wordpress-deploy-foldersync)

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
------------

[](#dependencies)

- The `rsync` linux command is used to perform the sync. So, it must be available via the command-line. You'll get a `RuntimeException` if you try to call `FolderSync::sync` without the `rsync` command.
- All other dependencies are defined in `composer.json`.

Install
-------

[](#install)

```
curl -s http://getcomposer.org/installer | php
php composer.phar require cullylarson/wp-deploy-folder-sync

```

Usage
-----

[](#usage)

Everything is done through an instance of the `Wordpress\Deploy\FolderSync`class.

### Construction

[](#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

[](#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

[](#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

[](#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

[](#example)

```
