Skip to content

Instantly share code, notes, and snippets.

@frankdejonge
Created July 23, 2015 10:10
Show Gist options
  • Save frankdejonge/bdad4961b7dfc0a4e698 to your computer and use it in GitHub Desktop.
Save frankdejonge/bdad4961b7dfc0a4e698 to your computer and use it in GitHub Desktop.
FTP to ZipArchive
<?php
$zipFilesystem = new Filesystem(new ZipArchiveAdapter($directory.'/zipname.zip'));
$ftpFilesystem = new Filesystem(new Ftp($ftpOptions));
$ftpFilesystem->addPlugin(new ListFiles);
$paths = $ftpFilesystem->listFiles($sourceDir, true);
foreach ($paths as $path) {
$stream = $ftpFilesystem->readStream($path);
$destination = substr($path, strlen($sourceDir));
$zipFilesystem->writeStream($destination, $stream);
fclose($stream);
}
// Force ZipArchive close
unset($zipFilesystem);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment