Created
July 23, 2015 10:10
-
-
Save frankdejonge/bdad4961b7dfc0a4e698 to your computer and use it in GitHub Desktop.
FTP to ZipArchive
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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