PHP code example of esplora / decompresso

1. Go to this page and download the library: Download esplora/decompresso 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/ */

    

esplora / decompresso example snippets


use Esplora\Lumos\FileProcessor;
use Esplora\Lumos\Adapters\ZipArchiveAdapter;
use Esplora\Lumos\Adapters\GzipArchiveAdapter;

// Create a new FileProcessor instance to manage file processing
$fileProcessor = new FileProcessor();

// Specify which file handlers will be used
$fileProcessor->withAdapters([
    new ZipArchiveAdapter(),
    new GzipArchiveAdapter(),
]);

// Process a file (returns a boolean depending on the outcome)
$fileProcessor->process('/path/to/your/archive.zip', '/path/to/extract/to');

use Esplora\Lumos\FileProcessor;
use Esplora\Lumos\Adapters\ZipArchiveAdapter;
use Esplora\Lumos\Providers\ArrayPasswordProvider;

$fileProcessor = new FileProcessor();

$fileProcessor
    ->withPasswords(new ArrayPasswordProvider([
        'qwerty',
        'xxx123',
    ]))
    ->withAdapters([
        new ZipArchiveAdapter(),
        // Add more adapters as needed
    ]);

// Process the file and returns a boolean depending on the outcome
$fileProcessor->process('/path/to/your/document.docx', '/path/to/save/to');

use Esplora\Lumos\FileProcessor;
use Esplora\Lumos\Handlers\ZipArchiveHandler;
use Esplora\Lumos\Providers\ArrayPasswordProvider;

$fileProcessor = new FileProcessor();

$fileProcessor
    ->withPasswords(new ArrayPasswordProvider([
        'qwerty',
        'xxx123',
    ]))
    ->withAdapters([
        new ZipArchiveAdapter(),
        // Add more adapters as needed
    ])
    
    // Define logic to execute on successful processing
    ->onSuccess(fn() => true)
    
    // Handle cases where processing fails due to an incorrect password
    ->onPasswordFailure(fn() => false)
    
    // Handle any other errors encountered during processing
    ->onFailure(fn() => false)

// Processes the file and returns the result of the closure
$fileProcessor->process('/path/to/your/archive.zip', '/path/to/extract/to');