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.1(1mo ago)46.0k↓10.6%[1 issues](https://github.com/PhpGt/Sync/issues)[4 PRs](https://github.com/PhpGt/Sync/pulls)2PHPPHP &gt;=8.0CI 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 1mo ago

READMEChangelog (10)Dependencies (6)Versions (26)Used By (2)

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)

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

53

—

FairBetter than 97% of packages

Maintenance84

Actively maintained with recent releases

Popularity27

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity75

Established project with proven stability

 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 ~159 days

Recently: every ~406 days

Total

17

Last Release

55d ago

Major Versions

v0.2.0 → v1.0.02019-03-23

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

v1.2.7PHP &gt;=8.0

### 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 (3 commits)")

---

Tags

copycopy-file-synccopy-filesfilesystemrecursiversyncsyncsynchronisationsynchronise-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.6k639.1M2.1k](/packages/league-flysystem)[league/flysystem-aws-s3-v3

AWS S3 filesystem adapter for Flysystem.

1.6k263.6M788](/packages/league-flysystem-aws-s3-v3)[league/flysystem-local

Local filesystem adapter for Flysystem.

226231.8M39](/packages/league-flysystem-local)[league/flysystem-memory

In-memory filesystem adapter for Flysystem.

8533.6M194](/packages/league-flysystem-memory)[league/flysystem-sftp-v3

SFTP filesystem adapter for Flysystem.

6129.6M91](/packages/league-flysystem-sftp-v3)[league/flysystem-ziparchive

ZIP filesystem adapter for Flysystem.

1039.3M58](/packages/league-flysystem-ziparchive)

PHPackages © 2026

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