PHPackages                             phpgt/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. [File &amp; Storage](/categories/file-storage)
4. /
5. phpgt/sync

ActiveLibrary[File &amp; Storage](/categories/file-storage)

phpgt/sync
==========

Synchronise two directories.

v1.3.2(2mo ago)46.9k—9.1%[3 PRs](https://github.com/PhpGt/Sync/pulls)3PHPPHP &gt;=8.2CI passing

Since Mar 18Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/PhpGt/Sync)[ Packagist](https://packagist.org/packages/phpgt/sync)[ GitHub Sponsors](https://github.com/sponsors/PhpGt)[ RSS](/packages/phpgt-sync/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (10)Dependencies (12)Versions (28)Used By (3)

Synchronise two directories.
============================

[](#synchronise-two-directories)

`rsync` is the tool of choice for ensuring that two directories have the same content, but is only present by default on Unix systems. This repository provides simple recursive directory synchronisation in plain PHP, compatible on Linux, Mac and Windows.

---

[ ![Build status](https://camo.githubusercontent.com/4093cce2c05f1d1d4402abb0c0b402889cdb780c4f5cf36a3b85aa0c1bc39fe8/68747470733a2f2f62616467652e7374617475732e7068702e67742f73796e632d6275696c642e737667)](https://github.com/PhpGt/Sync/actions)[ ![Code quality](https://camo.githubusercontent.com/9f5a4a83faf6e66d894a887a912ab30643eca4e981bff7fb9b3722ea4a7c3f6b/68747470733a2f2f62616467652e7374617475732e7068702e67742f73796e632d7175616c6974792e737667)](https://app.codacy.com/gh/PhpGt/Sync)[ ![Code coverage](https://camo.githubusercontent.com/4270c9a54623499a4f978e400804477c2dac3aa102f4f1a0a6a41ef26ed5c129/68747470733a2f2f62616467652e7374617475732e7068702e67742f73796e632d636f7665726167652e737667)](https://app.codecov.io/gh/PhpGt/Sync)[ ![Current version](https://camo.githubusercontent.com/247dd7109173fecc9cec65fa840ba8cdda515f24323b596cdea607a437ec27c2/68747470733a2f2f62616467652e7374617475732e7068702e67742f73796e632d76657273696f6e2e737667)](https://packagist.org/packages/PhpGt/Sync)[ ![PHP.Gt/Sync documentation](https://camo.githubusercontent.com/dc2c7e2fce5e3685cf97b17b2e4f81dac81fa01c06b335a53d17faaccbc38932/68747470733a2f2f62616467652e7374617475732e7068702e67742f73796e632d646f63732e737667)](http://www.php.gt/sync)Example usage
-------------

[](#example-usage)

```
use GT\Sync\DirectorySync;
use GT\Sync\SyncException;

$source = "/var/www/example.com";
$destination = "/var/backup/example.com";

try {
	$sync = new DirectorySync($source, $destination);
	$sync->exec(DirectorySync::COMPARE_FILEMTIME);
}
catch(SyncException $exception) {
	fwrite(STDERR, "Error performing sync: " . $exception->getMessage());
	exit(1);
}

echo "Sync complete!" . PHP_EOL;
echo "Changed: " . count($sync->getCopiedFilesList());
echo "Deleted: " . count($sync->getDeletedFilesList());
echo "Skipped: " . count($sync->getSkippedFilesList());
```

Features
--------

[](#features)

- Cross-platform compatible directory synchronisation (Linux, Windows, Mac).
- Selective sync through glob matches (only sync js files within script directory with `/script/**/*.js`).
- Get statistics of copied/deleted/skipped files after sync execution.
- Low memory footprint.

Proudly sponsored by
====================

[](#proudly-sponsored-by)

[JetBrains Open Source sponsorship program](https://www.jetbrains.com/community/opensource/)

[![JetBrains logo.](https://camo.githubusercontent.com/b5639e7738c6dfae9fe3f3e20175570b7376ce2577a772e09c25c2d4f14bf86e/68747470733a2f2f7265736f75726365732e6a6574627261696e732e636f6d2f73746f726167652f70726f64756374732f636f6d70616e792f6272616e642f6c6f676f732f6a6574627261696e732e737667)](https://www.jetbrains.com/community/opensource/)

###  Health Score

57

—

FairBetter than 98% of packages

Maintenance88

Actively maintained with recent releases

Popularity27

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity83

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~151 days

Recently: every ~409 days

Total

18

Last Release

77d ago

Major Versions

v0.2.0 → v1.0.02019-03-23

PHP version history (3 changes)v0.0.1PHP &gt;=7.2

v1.2.7PHP &gt;=8.0

v1.3.2PHP &gt;=8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/9e42344b91ce4b91ab57875969f67a0a6a48de570a08bc65d673b06b72fd3a3f?d=identicon)[g105b](/maintainers/g105b)

---

Top Contributors

[![g105b](https://avatars.githubusercontent.com/u/358014?v=4)](https://github.com/g105b "g105b (7 commits)")

---

Tags

copycopy-file-synccopy-filesfilesystemno-airecursiversyncsyncsynchronisationsynchronise-datasynchronizationsynchronize-filesfilesystemcopyfilefilesrecursivesynchronizersyncsynchronise

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/phpgt-sync/health.svg)

```
[![Health](https://phpackages.com/badges/phpgt-sync/health.svg)](https://phpackages.com/packages/phpgt-sync)
```

###  Alternatives

[league/flysystem

File storage abstraction for PHP

13.6k665.7M2.4k](/packages/league-flysystem)[league/flysystem-aws-s3-v3

AWS S3 filesystem adapter for Flysystem.

1.7k277.8M959](/packages/league-flysystem-aws-s3-v3)[league/flysystem-local

Local filesystem adapter for Flysystem.

224254.9M71](/packages/league-flysystem-local)[league/flysystem-memory

In-memory filesystem adapter for Flysystem.

8535.9M247](/packages/league-flysystem-memory)[league/flysystem-sftp-v3

SFTP filesystem adapter for Flysystem.

6133.1M132](/packages/league-flysystem-sftp-v3)[league/flysystem-ziparchive

ZIP filesystem adapter for Flysystem.

1039.6M70](/packages/league-flysystem-ziparchive)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
