public static function archiveFiles($fileOrFiles, $archiveName, $emulate = false)
    {
        if (file_exists($archiveName))
            throw new Exception('Archive '.$archiveName.' already exists!');

        self::checkRequirements();

        $archiveType = self::detectArchiveType($archiveName, false);
        //        if (in_array($archiveType, [TarArchive::TAR, TarArchive::TAR_GZIP, TarArchive::TAR_BZIP, TarArchive::TAR_LZMA, TarArchive::TAR_LZW], true))
        //            return TarArchive::archiveFiles($fileOrFiles, $archiveName, $emulate);
        if ($archiveType === false)
            return false;

        $files_list = self::createFilesList($fileOrFiles);
        if (empty($files_list))
            throw new InvalidArgumentException('Files list is empty!');

        // fake creation: return archive data
        if ($emulate) {
            $totalSize = 0;
            foreach ($files_list as $fn) $totalSize += filesize($fn);

            return array(
                'totalSize' => $totalSize,
                'numberOfFiles' => count($files_list),
                'files' => $files_list,
                'type' => $archiveType,
            );
        }

        if (!isset(static::$formatHandlers[$archiveType]))
            throw new Exception('Unsupported archive type: '.$archiveType.' of archive '.$archiveName);

        $handler_class = __NAMESPACE__.'\\Formats\\'.static::$formatHandlers[$archiveType];

        return $handler_class::createArchive($files_list, $archiveName);
    }
public static function archiveFiles($fileOrFiles, $archiveName, $emulate = false)
    {
        if (file_exists($archiveName))
            throw new Exception('Archive '.$archiveName.' already exists!');

        self::checkRequirements();

        $archiveType = self::detectArchiveType($archiveName, false);
        //        if (in_array($archiveType, [TarArchive::TAR, TarArchive::TAR_GZIP, TarArchive::TAR_BZIP, TarArchive::TAR_LZMA, TarArchive::TAR_LZW], true))
        //            return TarArchive::archiveFiles($fileOrFiles, $archiveName, $emulate);
        if ($archiveType === false)
            return false;

        $files_list = self::createFilesList($fileOrFiles);
        if (empty($files_list))
            throw new InvalidArgumentException('Files list is empty!');

        // fake creation: return archive data
        if ($emulate) {
            $totalSize = 0;
            foreach ($files_list as $fn) $totalSize += filesize($fn);

            return array(
                'totalSize' => $totalSize,
                'numberOfFiles' => count($files_list),
                'files' => $files_list,
                'type' => $archiveType,
            );
        }

        if (!isset(static::$formatHandlers[$archiveType]))
            throw new Exception('Unsupported archive type: '.$archiveType.' of archive '.$archiveName);

        $handler_class = __NAMESPACE__.'\\Formats\\'.static::$formatHandlers[$archiveType];

        return $handler_class::createArchive($files_list, $archiveName);
    }
public static function archiveFiles ( $ fileOrFiles , $ archiveName , $ emulate = false ) { if ( file_exists ( $ archiveName ) ) throw new Exception ( 'Archive ' . $ archiveName . ' already exists!' ) ; self :: checkRequirements ( ) ; $ archiveType = self :: detectArchiveType ( $ archiveName , false ) ; //        if (in_array($archiveType, [TarArchive::TAR, TarArchive::TAR_GZIP, TarArchive::TAR_BZIP, TarArchive::TAR_LZMA, TarArchive::TAR_LZW], true)) //            return TarArchive::archiveFiles($fileOrFiles, $archiveName, $emulate); if ( $ archiveType === false ) return false ; $ files_list = self :: createFilesList ( $ fileOrFiles ) ; if ( empty ( $ files_list ) ) throw new InvalidArgumentException ( 'Files list is empty!' ) ; // fake creation: return archive data if ( $ emulate ) { $ totalSize = 0 ; foreach ( $ files_list as $ fn ) $ totalSize += filesize ( $ fn ) ; return array ( 'totalSize' => $ totalSize , 'numberOfFiles' => count ( $ files_list ) , 'files' => $ files_list , 'type' => $ archiveType , ) ; } if ( ! isset ( static :: $ formatHandlers [ $ archiveType ] ) ) throw new Exception ( 'Unsupported archive type: ' . $ archiveType . ' of archive ' . $ archiveName ) ; $ handler_class = __NAMESPACE__ . '\\Formats\\' . static :: $ formatHandlers [ $ archiveType ] ; return $ handler_class :: createArchive ( $ files_list , $ archiveName ) ; }
Creates an archive with passed files list

@param string|string[]|array<string,string> $fileOrFiles List of files. Can be one of three formats:
1. A string containing path to file or directory.
File will have it's basename.
`UnifiedArchive::archiveFiles(['/etc/php.ini'], 'archive.zip)` will store
file with 'php.ini' name.
Directory contents will be stored in archive root.
`UnifiedArchive::archiveFiles(['/var/log/'], 'archive.zip')` will store all
directory contents in archive root.
2. An array with strings containing pats to files or directories.
Files and directories will be stored with full paths.
`UnifiedArchive::archiveFiles(['/etc/php.ini', '/var/log/'], 'archive.zip)`
will preserve full paths.
3. An array with strings where keys are strings.
Files will have name from key.
Directories contents will have prefix from key.
`UnifiedArchive::archiveFiles(['doc.txt' => 'very_long_name_of_document.txt',
'static' => '/var/www/html/static/'], 'archive.zip')`

@param string $archiveName File name of archive. Type of archive will be determined via it's name.
@param bool $emulate If true, emulation mode is performed instead of real archiving.

@return array|bool|int
@throws Exception
Creates an archive with passed files list