phpgt / sync
Synchronise two directories.
Fund package maintenance!
PhpGt
Installs: 5 342
Dependents: 3
Suggesters: 0
Security: 0
Stars: 3
Watchers: 3
Forks: 1
Open Issues: 6
Requires
- php: >=8.0
- phpgt/cli: ^1.3
- webmozart/glob: 4.4.*
Requires (Dev)
- phpmd/phpmd: ^2.13
- phpstan/phpstan: ^1.10
- phpunit/phpunit: ^10.1
- squizlabs/php_codesniffer: ^3.7
- dev-master
- v1.3.0
- v1.2.9
- v1.2.8
- v1.2.7
- v1.2.6
- v1.2.5
- v1.2.4
- v1.2.3
- v1.2.2
- v1.2.1
- v1.2.0
- v1.1.0
- v1.0.0
- v0.2.0
- v0.1.0
- v0.0.1
- dev-test-default-pattern
- dev-51-symlinks
- dev-dependabot/composer/phpunit/phpunit-9.6.5
- dev-dependabot/composer/phpstan/phpstan-1.10.6
- dev-dependabot/composer/webmozart/glob-4.6.0
This package is auto-updated.
Last update: 2024-10-17 17:00:12 UTC
README
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.
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
- 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.