composer require league/flysystem-sync
use League\Flysystem\Adapter\Ftp; use League\Flysystem\Adapter\Local; use League\Flysystem\Filesystem; use League\Flysystem\Sync\Synchronizer; $localAdapter = new Local('/path/to/local/directory'); $remoteAdapter = new Ftp([ 'host' => 'example.com', 'username' => 'username', 'password' => 'password', 'root' => '/path/to/remote/directory', ]); $localFs = new Filesystem($localAdapter); $remoteFs = new Filesystem($remoteAdapter); $synchronizer = new Synchronizer($localFs, $remoteFs); $synchronizer->sync();
use League\Flysystem\Adapter\Ftp; use League\Flysystem\Adapter\Local; use League\Flysystem\Filesystem; use League\Flysystem\Sync\Synchronizer; $localAdapter = new Local('/path/to/local/directory'); $remoteAdapter = new Ftp([ 'host' => 'example.com', 'username' => 'username', 'password' => 'password', 'root' => '/path/to/remote/directory', ]); $localFs = new Filesystem($localAdapter); $remoteFs = new Filesystem($remoteAdapter); $synchronizer = new Synchronizer($localFs, $remoteFs); $synchronizer->removeNonExisting();This example deletes files in the remote directory that don't exist in the local directory. The `removeNonExisting()` method performs this action. Overall, the league/flysystem-sync package library is a great tool for synchronizing directories and ensuring that their contents match at all times.