当前位置: 首页>>代码示例>>PHP>>正文


PHP Phar::compressFiles方法代码示例

本文整理汇总了PHP中Phar::compressFiles方法的典型用法代码示例。如果您正苦于以下问题:PHP Phar::compressFiles方法的具体用法?PHP Phar::compressFiles怎么用?PHP Phar::compressFiles使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Phar的用法示例。


在下文中一共展示了Phar::compressFiles方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: makePhar

function makePhar(array $dt)
{
    //retornando com erro se o array estiver vazio
    if (count($dt) <= 0) {
        return false;
    }
    //aumentando a memoria e o tempo de execução - pode ser muito significante em sistemas lentos e diretórios muito grandes
    ini_set('memory_limit', '30M');
    ini_set('max_execution_time', 180);
    //Array com os dados da execução
    $ok = array();
    //lendo e executando as conversões indicadas
    foreach ($dt as $k => $lote) {
        //checando se deve converter indice['r']
        if (!isset($lote['r'])) {
            continue;
        }
        $dir = trim($lote['o'], ' \\/');
        $stub = '<?php 
			Phar::interceptFileFuncs();
			Phar::mungServer(array(\'REQUEST_URI\', \'PHP_SELF\', \'SCRIPT_NAME\', \'SCRIPT_FILENAME\'));
			Phar::webPhar(\'\', \'\', \'404.php\');
			__HALT_COMPILER();';
        // include(\'phar://\' . __FILE__ . \'/' . $lote['i'] . '\');
        if (is_dir($dir)) {
            //criando arquivo PHAR
            $phar = new Phar(trim($lote['d'], ' \\/'));
            //pegando o diretório (e sub-diretórios) e arquivos contidos
            $phar->buildFromIterator(new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dir)), $dir);
            //criando o cabeçalho Stub
            $phar->setStub($stub);
            //carregando a assinatura
            if (file_exists(LIB . 'key.md5')) {
                $phar->setSignatureAlgorithm(Phar::MD5, file_get_contents(LIB . 'key.md5'));
            }
            //comprimindo os dados (exceto o Stub)
            $compactar = false;
            if (isset($lote['z'])) {
                $compactar = true;
                if (Phar::canCompress(Phar::GZ)) {
                    $phar->compressFiles(Phar::GZ);
                } elseif (Phar::canCompress(Phar::BZ2)) {
                    $phar->compressFiles(Phar::BZ2);
                }
            }
            //adicionando os dados de saída
            $ok[$k] = array('o' => $dir, 'd' => $lote['d'], 'z' => $compactar, 'i' => $lote['i']);
        } else {
            $ok[$k] = array('e' => 'O diretório "' . $dir . '" não existe!');
        }
    }
    if (count($ok) == 0) {
        return false;
    }
    return $ok;
}
开发者ID:elandio,项目名称:pizza-10,代码行数:56,代码来源:makephar.php

示例2: makePlugin

 /**
  * Makes a .phar packaged PocketMine plugin from a source directory.
  *
  * @param $sourcePath
  * @param $pharOutputLocation
  * @param $options
  * @return bool
  * @throws \Exception
  */
 public static function makePlugin($sourcePath, $pharOutputLocation, $options)
 {
     /* Removes Leading '/' */
     $sourcePath = rtrim(str_replace("\\", "/", realpath($sourcePath)), "/") . "/";
     $description = self::getPluginDescription($sourcePath . "/plugin.yml");
     if ($options & self::MAKEPLUGIN_REAL_OUTPUT_PATH) {
         $pharPath = $pharOutputLocation;
     } else {
         $pharPath = $pharOutputLocation . DIRECTORY_SEPARATOR . $description->getName() . "_v" . $description->getVersion() . ".phar";
     }
     if (file_exists($pharPath)) {
         throw new \Exception("Phar path already exists");
     }
     $phar = new \Phar($pharPath);
     $phar->setMetadata(["name" => $description->getName(), "version" => $description->getVersion(), "main" => $description->getMain(), "api" => $description->getCompatibleApis(), "depend" => $description->getDepend(), "description" => $description->getDescription(), "authors" => $description->getAuthors(), "website" => $description->getWebsite(), "creationDate" => time()]);
     $phar->setStub('<?php echo "PocketMine-MP plugin ' . $description->getName() . ' v' . $description->getVersion() . '\\nThis file has been generated using DevTools v' . self::getVersion() . ' at ' . date("r") . '\\n----------------\\n";if(extension_loaded("phar")){$phar = new \\Phar(__FILE__);foreach($phar->getMetadata() as $key => $value){echo ucfirst($key).": ".(is_array($value) ? implode(", ", $value):$value)."\\n";}} __HALT_COMPILER();');
     $phar->setSignatureAlgorithm(\Phar::SHA1);
     $phar->startBuffering();
     foreach (new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($sourcePath)) as $file) {
         $path = ltrim(str_replace(["\\", $sourcePath], ["/", ""], $file), "/");
         if ($path[0] === "." or strpos($path, "/.") !== false) {
             continue;
         }
         $phar->addFile($file, $path);
     }
     if ($options * self::MAKEPLUGIN_COMPRESS) {
         $phar->compressFiles(\Phar::GZ);
     }
     $phar->stopBuffering();
     return true;
 }
开发者ID:sekjun9878,项目名称:makeplugin,代码行数:40,代码来源:MakePlugin.php

示例3: run

 public function run()
 {
     $this->printTaskInfo("Creating <info>{$this->filename}</info>");
     $this->phar->setSignatureAlgorithm(\Phar::SHA1);
     $this->phar->startBuffering();
     $this->printTaskInfo('Packing ' . count($this->files) . ' files into phar');
     $progress = new ProgressBar($this->getOutput());
     $progress->start(count($this->files));
     $this->startTimer();
     foreach ($this->files as $path => $content) {
         $this->phar->addFromString($path, $content);
         $progress->advance();
     }
     $this->phar->stopBuffering();
     $progress->finish();
     $this->getOutput()->writeln('');
     if ($this->compress and in_array('GZ', \Phar::getSupportedCompression())) {
         if (count($this->files) > 1000) {
             $this->printTaskInfo("Too many files. Compression DISABLED");
         } else {
             $this->printTaskInfo($this->filename . " compressed");
             $this->phar = $this->phar->compressFiles(\Phar::GZ);
         }
     }
     $this->stopTimer();
     $this->printTaskSuccess("<info>{$this->filename}</info> produced");
     return Result::success($this, '', ['time' => $this->getExecutionTime()]);
 }
开发者ID:roland-d,项目名称:Robo,代码行数:28,代码来源:PackPhar.php

示例4: run

 public function run()
 {
     $this->printTaskInfo('Creating {filename}', ['filename' => $this->filename]);
     $this->phar->setSignatureAlgorithm(\Phar::SHA1);
     $this->phar->startBuffering();
     $this->printTaskInfo('Packing {file-count} files into phar', ['file-count' => count($this->files)]);
     $this->startProgressIndicator();
     foreach ($this->files as $path => $content) {
         $this->phar->addFromString($path, $content);
         $this->advanceProgressIndicator();
     }
     $this->phar->stopBuffering();
     $this->advanceProgressIndicator();
     if ($this->compress and in_array('GZ', \Phar::getSupportedCompression())) {
         if (count($this->files) > 1000) {
             $this->printTaskInfo('Too many files. Compression DISABLED');
         } else {
             $this->printTaskInfo('{filename} compressed', ['filename' => $this->filename]);
             $this->phar = $this->phar->compressFiles(\Phar::GZ);
         }
     }
     $this->advanceProgressIndicator();
     $this->stopProgressIndicator();
     $this->printTaskSuccess('{filename} produced', ['filename' => $this->filename]);
     return Result::success($this, '', ['time' => $this->getExecutionTime()]);
 }
开发者ID:greg-1-anderson,项目名称:Robo,代码行数:26,代码来源:PackPhar.php

示例5: testReading

    /**
     * Test that the reading is successful.
     *
     * @return void
     *
     * @dataProvider testReadingFlagsProvider
     */
    public function testReading($compression, $signatureName, $signatureFlag)
    {
        $pharfile = $this->getTempFile('temp.phar');
        $phar = new \Phar($pharfile, 0, 'temp.phar');
        $phar->startBuffering();
        $phar->addFromString('/bin/script', $fileData = <<<EOF
#!/usr/bin/php
<?php
echo 'hello world';
EOF
);
        $phar->setDefaultStub('/bin/script', '/web/index');
        $phar->stopBuffering();
        $phar->setSignatureAlgorithm($signatureFlag);
        if ($compression !== \Phar::NONE) {
            $phar->compressFiles($compression);
        }
        unset($phar);
        $reader = new PharReader();
        $phar = $reader->load($pharfile);
        $this->assertEquals('temp.phar', $phar->getAlias());
        $this->assertTrue($phar->isSigned());
        $this->assertEquals($signatureName, $phar->getSignatureAlgorithm());
        $files = $phar->getFiles();
        $this->assertEquals('bin/script', $files[0]->getFilename());
        $this->assertEquals($fileData, $files[0]->getContent());
    }
开发者ID:cyberspectrum,项目名称:pharpiler,代码行数:34,代码来源:PharReaderTest.php

示例6: close

 /**
  * Finish saving the package
  */
 function close()
 {
     if ($this->phar->isFileFormat(Phar::ZIP) && $this->compression !== Phar::NONE) {
         $this->phar->compressFiles($this->compression);
     }
     $this->phar->stopBuffering();
     $newphar = $this->phar;
     $ext = str_replace(array('.tar', '.zip', '.tgz', '.phar'), array('', '', '', ''), basename($this->path)) . '.';
     $ext = substr($ext, strpos($ext, '.'));
     if (count($this->others)) {
         foreach ($this->others as $pathinfo) {
             // remove the old file
             $newpath = str_replace(array('.tar', '.zip', '.tgz', '.phar'), array('', '', '', ''), $this->path);
             $newpath .= '.' . $pathinfo[0];
             if (file_exists($newpath)) {
                 unlink($newpath);
             }
             $extension = $ext . $pathinfo[0];
             $fileformat = $pathinfo[1];
             $compression = $pathinfo[2];
             if ($fileformat != Phar::PHAR) {
                 $newphar = $newphar->convertToData($fileformat, $compression, $extension);
             } else {
                 $newphar = $newphar->convertToExecutable($fileformat, $compression, $extension);
             }
         }
     }
 }
开发者ID:peopleplan,项目名称:Pyrus,代码行数:31,代码来源:Phar.php

示例7: convertVendorsToPhar

 public static function convertVendorsToPhar(Event $event)
 {
     $vendorDir = __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'vendor';
     $phars = [];
     echo "Converting vendor package dirs to phar...\n";
     foreach (new \DirectoryIterator($vendorDir) as $dir) {
         if (in_array($dir->getFilename(), ['..', '.', 'composer']) || !$dir->isDir()) {
             continue;
         }
         foreach (new \DirectoryIterator($dir->getRealPath()) as $subDir) {
             if (in_array($subDir->getFilename(), ['..', '.']) || !$subDir->isDir()) {
                 continue;
             }
             echo "... " . $dir->getFilename() . '/' . $subDir->getFilename() . "\n";
             $fName = $subDir->getRealPath() . '.phar';
             $fNameTmp = $fName . '.tmp';
             $phar = new \Phar($fNameTmp);
             $phar->buildFromDirectory($subDir->getRealPath(), '#\\.(?!git)#');
             if (\Phar::canCompress(\Phar::GZ)) {
                 $phar->compressFiles(\Phar::GZ);
             } else {
                 if (\Phar::canCompress(\Phar::BZ2)) {
                     $phar->compressFiles(\Phar::BZ2);
                 }
             }
             if (file_exists($fName)) {
                 unlink($fName);
             }
             unset($phar);
             rename($fNameTmp, $fName);
             //delDirTree($subDir->getRealPath());
             $phars[$dir->getFilename() . '/' . $subDir->getFilename()] = str_replace(DIRECTORY_SEPARATOR, '/', str_replace($vendorDir, '', $fName));
         }
     }
     echo "\nConverting autoload files: \n";
     $autoloadFiles = ['composer/autoload_classmap.php', 'composer/autoload_files.php', 'composer/autoload_namespaces.php', 'composer/autoload_psr4.php'];
     foreach ($autoloadFiles as $file) {
         echo $file . "\n";
         $filePath = $vendorDir . DIRECTORY_SEPARATOR . $file;
         $content = file_get_contents($filePath);
         $content = preg_replace('#(?<!\'phar://\' . )\\$vendorDir\\s+.\\s+\'(/[-\\w\\d_]+/[-\\w\\d_]+)#', '\'phar://\' . $vendorDir . \'$1.phar', $content);
         if ($content) {
             file_put_contents($filePath, $content);
         }
     }
     echo "\nComplete!\n";
 }
开发者ID:scottleedavis,项目名称:hackazon,代码行数:47,代码来源:ComposerPharMaker.php

示例8: build_phar

function build_phar()
{
    $phar = new Phar('build/bugsnag.phar');
    $phar->buildFromDirectory(dirname(__FILE__) . '/src', '/\\.php$/');
    $phar->compressFiles(Phar::GZ);
    $phar->stopBuffering();
    $phar->setStub($phar->createDefaultStub('Bugsnag/Autoload.php'));
}
开发者ID:ayurmedia,项目名称:faveo-helpdesk,代码行数:8,代码来源:pharbuilder.php

示例9: create

 static function create($phar_file, $php_dir, $default_stub)
 {
     $phar = new \Phar($phar_file);
     $phar->buildFromDirectory($php_dir, '/\\.php$/');
     $phar->compressFiles(\Phar::GZ);
     $phar->stopBuffering();
     $phar->setStub($phar->createDefaultStub($default_stub));
 }
开发者ID:jasonshaw,项目名称:framework-1,代码行数:8,代码来源:Phar.php

示例10: execute

 public function execute(CommandSender $sender, $commandLabel, array $args)
 {
     if (!$this->testPermission($sender)) {
         return false;
     }
     if (count($args) === 0) {
         $sender->sendMessage(TextFormat::RED . "Usage: " . $this->usageMessage);
         return true;
     }
     $pluginName = trim(implode(" ", $args));
     if ($pluginName === "" or !($plugin = Server::getInstance()->getPluginManager()->getPlugin($pluginName)) instanceof Plugin) {
         $sender->sendMessage(TextFormat::RED . "プラグインが存在しません");
         return true;
     }
     $description = $plugin->getDescription();
     if (!$plugin->getPluginLoader() instanceof FolderPluginLoader) {
         $sender->sendMessage(TextFormat::RED . "プラグイン " . $description->getName() . "はフォルダではありません");
         return true;
     }
     $pharPath = Server::getInstance()->getPluginPath() . DIRECTORY_SEPARATOR . "PocketMine-MO" . DIRECTORY_SEPARATOR . $description->getName() . "_v" . $description->getVersion() . ".phar";
     if (file_exists($pharPath)) {
         $sender->sendMessage("pharファイルが既に存在しているため、上書きします");
         @unlink($pharPath);
     }
     $phar = new \Phar($pharPath);
     $phar->setMetadata(["name" => $description->getName(), "version" => $description->getVersion(), "main" => $description->getMain(), "api" => $description->getCompatibleApis(), "geniapi" => $description->getCompatibleGeniApis(), "depend" => $description->getDepend(), "description" => $description->getDescription(), "authors" => $description->getAuthors(), "website" => $description->getWebsite(), "creator" => "PocketMine-MO MakePluginCommand", "creationDate" => time()]);
     if ($description->getName() === "DevTools") {
         $phar->setStub('<?php require("phar://". __FILE__ ."/src/DevTools/ConsoleScript.php"); __HALT_COMPILER();');
     } else {
         $phar->setStub('<?php echo "PocketMine-MP/ plugin ' . $description->getName() . ' v' . $description->getVersion() . '\\nThis file has been generated using PocketMine-MO by Meshida at ' . date("r") . '\\n----------------\\n";if(extension_loaded("phar")){$phar = new \\Phar(__FILE__);foreach($phar->getMetadata() as $key => $value){echo ucfirst($key).": ".(is_array($value) ? implode(", ", $value):$value)."\\n";}} __HALT_COMPILER();');
     }
     $phar->setSignatureAlgorithm(\Phar::SHA1);
     $reflection = new \ReflectionClass("pocketmine\\plugin\\PluginBase");
     $file = $reflection->getProperty("file");
     $file->setAccessible(true);
     $filePath = rtrim(str_replace("\\", "/", $file->getValue($plugin)), "/") . "/";
     $phar->startBuffering();
     foreach (new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($filePath)) as $file) {
         $path = ltrim(str_replace(["\\", $filePath], ["/", ""], $file), "/");
         if ($path[0] === "." or strpos($path, "/.") !== false) {
             continue;
         }
         $phar->addFile($file, $path);
         $sender->sendMessage($path . "を追加しています...");
     }
     foreach ($phar as $file => $finfo) {
         /** @var \PharFileInfo $finfo */
         if ($finfo->getSize() > 1024 * 512) {
             $finfo->compress(\Phar::GZ);
         }
     }
     if (!isset($args[1]) or isset($args[1]) and $args[1] != "nogz") {
         $phar->compressFiles(\Phar::GZ);
     }
     $phar->stopBuffering();
     $sender->sendMessage("pharプラグイン " . $description->getName() . " v" . $description->getVersion() . " は" . $pharPath . "上に生成されました");
     return true;
 }
开发者ID:AnonymousProjects,项目名称:PocketMine-MP-Original,代码行数:58,代码来源:MakePluginCommand.php

示例11: finalize

 /**
  * Finalize the project.
  *
  * @return void
  */
 public function finalize()
 {
     // disabled for interoperability with systems without gzip ext
     $this->phar->compressFiles(\Phar::GZ);
     $filename = $this->configuration->get('phar');
     $this->phar->getPharchive()->setAlias(basename($filename));
     $writer = new PharWriter();
     $writer->save($this->phar->getPharchive(), $filename);
     unset($this->phar);
     chmod($filename, 0755);
 }
开发者ID:cyberspectrum,项目名称:pharpiler,代码行数:16,代码来源:Project.php

示例12: createPharFile

function createPharFile($pharFilePath, $originalFile)
{
    $originalFile = realpath($originalFile);
    try {
        $phar = new Phar($pharFilePath);
        $phar->addFile($originalFile);
        $phar->compressFiles(Phar::GZ);
        $phar->stopBuffering();
        $phar->setStub($phar->createDefaultStub($pharFilePath));
        $phar->setStub("<?php Phar::mapPhar();\ninclude 'phar://{$pharFilePath}/{$originalFile}'; __HALT_COMPILER(); ?>");
    } catch (Exception $e) {
        var_dump($e->getMessage());
    }
}
开发者ID:poyu007,项目名称:heisoo_env,代码行数:14,代码来源:toPhar.php

示例13: makeServerCommand

 private function makeServerCommand(CommandSender $sender, Command $command, $label, array $args)
 {
     $server = Server::getInstance();
     $pharPath = \pocketmine\DATA . $server->getName() . "_translate.phar";
     if (file_exists($pharPath)) {
         $sender->sendMessage($server->getName() . "_translate.phar" . $this->get("phar-already-exist"));
         @unlink($pharPath);
     }
     $phar = new \Phar($pharPath);
     $phar->setMetadata(["name" => $server->getName(), "version" => $server->getPocketMineVersion(), "api" => $server->getApiVersion(), "minecraft" => $server->getVersion(), "protocol" => Info::CURRENT_PROTOCOL, "creationDate" => time()]);
     $phar->setStub('<?php define("pocketmine\\\\PATH", "phar://". __FILE__ ."/"); require_once("phar://". __FILE__ ."/src/pocketmine/PocketMine.php");  __HALT_COMPILER();');
     $phar->setSignatureAlgorithm(\Phar::SHA1);
     $phar->startBuffering();
     $filePath = substr(\pocketmine\PATH, 0, 7) === "phar://" ? \pocketmine\PATH : realpath(\pocketmine\PATH) . "/";
     $filePath = rtrim(str_replace("\\", "/", $filePath), "/") . "/";
     foreach (new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($filePath . "src")) as $file) {
         $path = ltrim(str_replace(array("\\", $filePath), array("/", ""), $file), "/");
         if ($path[0] === "." or strpos($path, "/.") !== false or substr($path, 0, 4) !== "src/") {
             continue;
         }
         echo "추가 중... " . $file->getFilename() . "\n";
         foreach ($this->messages["translation"][$args[0]] as $index => $phpfile) {
             if ($file->getFilename() == $index) {
                 $translate = file_get_contents($file);
                 // TODO
                 foreach ($this->messages["translation"][$args[0]][$file->getFilename()] as $index => $text) {
                     $translate = str_replace($index, $text, $translate);
                     echo "변경완료 [{$index}] [{$text}]\n";
                 }
                 if (!file_exists(\pocketmine\DATA . "extract/" . explode($file->getFilename(), $path)[0])) {
                     mkdir(\pocketmine\DATA . "extract/" . explode($file->getFilename(), $path)[0], 0777, true);
                 }
                 echo "폴더생성 " . \pocketmine\DATA . "extract/" . explode($file->getFilename(), $path)[0] . "\n";
                 file_put_contents(\pocketmine\DATA . "extract/" . $path, $translate);
                 break;
             }
         }
         if (file_exists(\pocketmine\DATA . "extract/" . $path)) {
             $phar->addFile(\pocketmine\DATA . "extract/" . $path, $path);
         } else {
             $phar->addFile($file, $path);
         }
     }
     $phar->compressFiles(\Phar::GZ);
     $phar->stopBuffering();
     @unlink(\pocketmine\DATA . "extract/");
     $sender->sendMessage($server->getName() . "_translate.phar" . $this->get("phar-translate-complete") . $pharPath);
     return true;
 }
开发者ID:EmreTr1,项目名称:rtr,代码行数:49,代码来源:Babel.php

示例14: close

 /**
  * Finish saving the package
  */
 function close()
 {
     if ($this->phar->isFileFormat(\Phar::ZIP) && $this->compression !== \Phar::NONE) {
         $this->phar->compressFiles($this->compression);
     }
     if (null !== $this->pkcs12) {
         $certpath = str_replace(array('.tar', '.zip', '.tgz', '.phar'), array('', '', '', ''), $this->path);
         $this->phar->setSignatureAlgorithm(\Phar::OPENSSL, $this->privatekey);
         file_put_contents($certpath . '.pem', $this->x509cert);
         file_put_contents($this->path . '.pubkey', $this->publickey);
     } elseif (!$this->phar->isFileFormat(\Phar::ZIP)) {
         $this->phar->setSignatureAlgorithm(\Phar::SHA1);
     }
     $this->phar->stopBuffering();
     $ext = str_replace(array('.tar', '.zip', '.tgz', '.phar'), array('', '', '', ''), basename($this->path)) . '.';
     $ext = substr($ext, strpos($ext, '.'));
     $newphar = $this->phar;
     if (count($this->others)) {
         foreach ($this->others as $pathinfo) {
             // remove the old file
             $pubkeypath = $newpath = str_replace(array('.tar', '.zip', '.tgz', '.phar'), array('', '', '', ''), $this->path);
             $newpath .= '.' . $pathinfo[0];
             if (file_exists($newpath)) {
                 unlink($newpath);
             }
             $extension = $ext . $pathinfo[0];
             $fileformat = $pathinfo[1];
             $compression = $pathinfo[2];
             if ($fileformat != \Phar::PHAR) {
                 $newphar = $newphar->convertToData($fileformat, $compression, $extension);
             } else {
                 $newphar = $newphar->convertToExecutable($fileformat, $compression, $extension);
             }
             if (isset($pkey)) {
                 $newphar->setSignatureAlgorithm(\Phar::OPENSSL, $this->privatekey);
                 file_put_contents($pubkeypath . '.' . $pathinfo[0] . '.pubkey', $this->publickey);
             } else {
                 $newphar->setSignatureAlgorithm(\Phar::SHA1);
             }
         }
     }
 }
开发者ID:rosstuck,项目名称:PEAR2_Pyrus,代码行数:45,代码来源:Phar.php

示例15: run

 public function run()
 {
     $this->printTaskInfo("creating <info>{$this->filename}</info>");
     $this->phar->setSignatureAlgorithm(\Phar::SHA1);
     $this->phar->startBuffering();
     $this->printTaskInfo('packing ' . count($this->files) . ' files into phar');
     $progress = new ProgressHelper();
     $progress->start($this->getOutput(), count($this->files));
     foreach ($this->files as $path => $content) {
         $this->phar->addFromString($path, $content);
         $progress->advance();
     }
     $this->phar->stopBuffering();
     $progress->finish();
     if ($this->compress and in_array('GZ', \Phar::getSupportedCompression())) {
         $this->printTaskInfo($this->filename . " compressed");
         $this->phar = $this->phar->compressFiles(\Phar::GZ);
     }
     $this->printTaskInfo($this->filename . " produced");
     return Result::success($this);
 }
开发者ID:sliver,项目名称:Robo,代码行数:21,代码来源:PackPhar.php


注:本文中的Phar::compressFiles方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。