PHP code example of ride / lib-archive

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

    

ride / lib-archive example snippets




use ride\library\archive\ZipArchive;
use ride\library\system\file\FileSystem;

function createArchive(FileSystem $fileSystem) {
    // create the archive
    $archiveFile = $fileSystem->getTemporaryFile();
    $archive = new ZipArchive($archiveFile);

    // compress single file in the root of the archive
    $file = $fileSystem->getFile('/my/file');
    $archive->compress($file);

    // compress multiple files in a folder in the archive
    $files = array(
        $fileSystem->getFile('/my/second-file'),
        $fileSystem->getFile('/my/third-file'),
    );
    $archive->compress($files, 'path/in/archive'); 

    // we're done here
    return $archiveFile;
}