PHP code example of gromnan / s3-zip

1. Go to this page and download the library: Download gromnan/s3-zip library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

gromnan / s3-zip example snippets


use AsyncAws\S3\S3Client;
use GromNaN\S3Zip\Archive;
use GromNaN\S3Zip\Input\S3Input;
use Symfony\Component\HttpClient\HttpClient;
use Symfony\Component\HttpKernel\Log\Logger;

$logger = new Logger();
$httpClient = HttpClient::create()->setLogger($logger);
$s3 = new S3Client([/* AWS Config */], null, $httpClient, $logger);

$filename = 's3://my-bucket/path/to/archive.zip';

$input = new S3Input($s3, $filename);
$input->setLogger($logger);

$archive = new Archive($input);

// Get the list for file names in the archive
var_dump($archive->getFileNames());

// Downloads and extracts the contents of a single file
echo $archive->getFile('path/to/file/in/archive.txt')->getContents();