![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/ts.corals.io/corals-api/vendor/maennchen/zipstream-php/guides/ |
Usage with FlySystem =============== For saving or uploading the generated zip, you can use the `Flysystem <https://flysystem.thephpleague.com>`_ package, and its many adapters. For that you will need to provide another stream than the ``php://output`` default one, and pass it to Flysystem ``putStream`` method. .. code-block:: php // Open Stream only once for read and write since it's a memory stream and // the content is lost when closing the stream / opening another one $tempStream = fopen('php://memory', 'w+'); // Init Options $zipStreamOptions = new Archive(); $zipStreamOptions->setOutputStream($tempStream); // Create Zip Archive $zipStream = new ZipStream('test.zip', $zipStreamOptions); $zipStream->addFile('test.txt', 'text'); $zipStream->finish(); // Store File (see Flysystem documentation, and all its framework integration) $adapter = new Local(__DIR__.'/path/to/folder'); // Can be any adapter (AWS, Google, Ftp, etc.) $filesystem = new Filesystem($adapter); $filesystem->putStream('test.zip', $tempStream) // Close Stream fclose($tempStream);