Skip to content

Instantly share code, notes, and snippets.

@rachelbaker
Last active December 18, 2015 19:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rachelbaker/d8de958ff5cfe63c6d12 to your computer and use it in GitHub Desktop.
Save rachelbaker/d8de958ff5cfe63c6d12 to your computer and use it in GitHub Desktop.
public function zip_file()
{
$zipFile = $this->_plugin_path . 'assets/temp_files' . date("Y-m-d-h-i-s-"). 'test.zip';
$zip = new ZipArchive;
$opened = $zip->open($zipFile, ZIPARCHIVE::CREATE);
if( $opened !== true ){
// return early
die("cannot open {$zipFile} for writing.");
}
// DO STUFF
$zip->close();
return $zip;
}
@rachelbaker
Copy link
Author

I removed the logic for setting the content headers, to limit the points of failure in this method. Don't forget to re-add them once confirming the zip file is created and returning correctly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment