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


PHP PharData::buildFromDirectory方法代码示例

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


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

示例1: testAutoRollback

 public function testAutoRollback()
 {
     // Setup
     $this->autoRollbackHelper();
     $this->backupFile->buildFromDirectory($this->archivedDir);
     $this->backupFile->addEmptyDir("testDirectory");
     $this->backupFile->compress(\Phar::GZ, '.tgz');
     $newFile = $this->backupPath . '/' . uniqid() . '_code.tgz';
     copy($this->backupFileName, $newFile);
     if (file_exists($this->backupFileName)) {
         unset($this->backupFile);
         unlink($this->backupFileName);
     }
     $gtzFile = str_replace('tar', 'tgz', $this->backupFileName);
     if (file_exists($gtzFile)) {
         unlink($gtzFile);
     }
     $this->backupFileName = $newFile;
     // Change the contents of a.txt
     $this->autoRollbackHelper(1);
     $this->assertEquals('foo changed', file_get_contents($this->archivedDir . 'a.txt'));
     $this->backupInfo->expects($this->once())->method('getBlacklist')->willReturn(['excluded']);
     // Rollback process
     $this->rollBack->execute($this->backupFileName);
     // Assert that the contents of a.txt has been restored properly
     $this->assertEquals('foo', file_get_contents($this->archivedDir . 'a.txt'));
 }
开发者ID:Dalerion83,项目名称:magento2-community-edition,代码行数:27,代码来源:RollbackTest.php

示例2: addDir

 /**
  * @inheritDoc
  */
 public function addDir($dir)
 {
     try {
         $this->phar->buildFromDirectory($dir);
     } catch (\PharException $e) {
         return false;
     }
     return true;
 }
开发者ID:ambient-lounge,项目名称:site,代码行数:12,代码来源:PharArchiveCreator.php

示例3: test_load_extension

 /**
  * @covers common\classes\AutoLoader::load_extension
  */
 public function test_load_extension()
 {
     $extensions = glob(ROOT_PATH . DS . 'extensions' . DS . '*');
     foreach ($extensions as $extension) {
         $name = ucwords(explode('.', basename($extension))[0]);
         self::assertTrue(AutoLoader::load_extension($name));
     }
     self::assertFalse(AutoLoader::load_extension('NotExistedClass'));
     $name = 'fakeextension';
     $extension_file = ROOT_PATH . DS . 'extensions' . DS . $name;
     $extension_build_dir = ROOT_PATH . DS . 'tests' . DS . 'resource' . DS . $name;
     $extension_file_tar = "{$extension_file}.tar";
     $extension_file_gz = "{$extension_file}.tar.gz";
     if (file_exists($extension_file_gz)) {
         Phar::unlinkArchive($extension_file_gz);
     }
     $phar = new PharData($extension_file_tar);
     $phar->buildFromDirectory($extension_build_dir);
     $phar->compress(Phar::GZ);
     if (file_exists($extension_file_tar)) {
         unlink($extension_file_tar);
     }
     self::assertTrue(AutoLoader::load_extension($name));
     unlink($extension_file_gz);
 }
开发者ID:one-more,项目名称:peach_framework,代码行数:28,代码来源:AutoloaderTest.php

示例4: __construct

 /**
  * Files constructor.
  * @param $target
  */
 public function __construct($target)
 {
     $this->tarFilename = sys_get_temp_dir() . '/' . uniqid() . '.tar';
     $phar = new \PharData($this->tarFilename);
     $phar->buildFromDirectory($target);
     $this->tarStream = fopen($this->tarFilename, 'r');
 }
开发者ID:jarkt,项目名称:dockercloud-php-client,代码行数:11,代码来源:Files.php

示例5: gzipFolder

 static function gzipFolder($folder) {
     try {
         $a = new PharData($folder . '_archive.zip');
         $a->buildFromDirectory($folder);
     } catch (Exception $e) {
         return false;
     } return true;
 }
开发者ID:salatproduction,项目名称:XLSX-2-HTML-SQL-Converter-Standalone,代码行数:8,代码来源:functions.class.php

示例6: backupSwitchedOff

 /**
  * Internal. Backup server when it's not running
  * @param string $path
  * @param string $filename
  * @return boolean
  */
 private function backupSwitchedOff($path, $filename)
 {
     try {
         $phar = new PharData($path . 'backups/' . $filename . '.zip');
         $phar->buildFromDirectory($path . 'world/');
         return TRUE;
     } catch (UnexpectedValueException $e) {
         echo $e->getMessage();
         return FALSE;
     }
 }
开发者ID:VNovotna,项目名称:MP2014,代码行数:17,代码来源:BackupModel.php

示例7: backupFolder

 /**
  * @param string $folder
  *
  * @return bool
  */
 protected function backupFolder($folder)
 {
     GeneralUtility::mkdir_deep($this->backupPath);
     $compressedFileName = $folder . '_' . time() . '.tar';
     $phar = new \PharData($this->backupPath . $compressedFileName);
     if ($phar->buildFromDirectory(PATH_site . $folder, '/^(?!_temp_|_processed_|_recycler_).*/')) {
         BackupUtility::generateBackupLog($folder, $compressedFileName . '.gz', $this->backupPath, $this->backupsToKeep);
         BackupUtility::gzCompressFile($this->backupPath . $compressedFileName);
         return true;
     }
     return false;
 }
开发者ID:markussom,项目名称:backup_me,代码行数:17,代码来源:BackupCommandController.php

示例8: execute

 /**
  * @param InputInterface $input
  * @param OutputInterface $output
  * @return int|null|void
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     parent::execute($input, $output);
     $language = $input->getArgument('language');
     $tmpFolder = $input->getOption('tmp');
     $_configuration = $this->getHelper('configuration')->getConfiguration();
     $connection = $this->getHelper('configuration')->getConnection();
     if ($connection) {
         $lang = isset($language) ? $language : null;
         $lang = mysql_real_escape_string($lang);
         $q = mysql_query("SELECT * FROM language WHERE english_name = '{$lang}' ");
         $langInfo = mysql_fetch_array($q, MYSQL_ASSOC);
         if (!$langInfo) {
             $output->writeln("<comment>Language '{$lang}' is not registered in the Chamilo Database</comment>");
             $q = mysql_query("SELECT * FROM language WHERE parent_id IS NULL or parent_id = 0");
             $output->writeln("<comment>Available languages are: </comment>");
             while ($langRow = mysql_fetch_array($q, MYSQL_ASSOC)) {
                 $output->write($langRow['english_name'] . ", ");
             }
             $output->writeln(' ');
             $q = mysql_query("SELECT * FROM language WHERE parent_id <> 0");
             $output->writeln("<comment>Available sub languages are: </comment>");
             while ($langRow = mysql_fetch_array($q, MYSQL_ASSOC)) {
                 $output->write($langRow['english_name'] . ", ");
             }
             $output->writeln(' ');
             exit;
         } else {
             $output->writeln("<comment>Language</comment> <info>'{$lang}'</info> <comment>is registered in the Chamilo installation with iso code: </comment><info>{$langInfo['isocode']} </info>");
         }
         $langFolder = $_configuration['root_sys'] . 'main/lang/' . $lang;
         if (!is_dir($langFolder)) {
             $output->writeln("<comment>Language '{$lang}' does not exist in the path: {$langFolder}</comment>");
         }
         if (empty($tmpFolder)) {
             $tmpFolder = '/tmp/';
             $output->writeln("<comment>No temporary directory defined. Assuming /tmp/. Please make sure you have *enough space* left on that device");
         }
         if (!is_dir($tmpFolder)) {
             $output->writeln("<comment>Temporary directory: {$tmpFolder} is not a valid dir path, using /tmp/ </comment>");
             $tmpFolder = '/tmp/';
         }
         if ($langInfo) {
             $output->writeln("<comment>Creating translation package</comment>");
             $fileName = $tmpFolder . $langInfo['english_name'] . '.tar';
             $phar = new \PharData($fileName);
             $phar->buildFromDirectory($langFolder);
             $phar->setMetadata($langInfo);
             $output->writeln("<comment>File created:</comment> <info>{$fileName}</info>");
         }
     }
 }
开发者ID:ilosada,项目名称:chamilo-lms-icpna,代码行数:57,代码来源:ExportLanguageCommand.php

示例9: build_extension

 private static function build_extension($name)
 {
     $name = strtolower($name);
     $extension_file = ROOT_PATH . DS . 'extensions' . DS . $name;
     $extension_build_dir = ROOT_PATH . DS . 'build' . DS . $name;
     $extension_file_tar = "{$extension_file}.tar";
     $extension_file_gz = "{$extension_file}.tar.gz";
     if (file_exists($extension_file_gz)) {
         \Phar::unlinkArchive($extension_file_gz);
     }
     $phar = new \PharData($extension_file_tar);
     $phar->buildFromDirectory($extension_build_dir);
     $phar->compress(\Phar::GZ);
     if (file_exists($extension_file_tar)) {
         unlink($extension_file_tar);
     }
 }
开发者ID:one-more,项目名称:peach_framework,代码行数:17,代码来源:autoloader.php

示例10: zip

 public function zip($from, $to)
 {
     if (!is_dir($from) || !is_readable($from)) {
         throw new Exception('Extension dir doesn\'t not exist or is not a readable directory');
     }
     $outputDir = dirname($to);
     if (!is_dir($outputDir) || !is_writable($outputDir)) {
         throw new Exception('Output dir doesn\'t not exist or is not a writable directory');
     }
     $phar = new PharData($to, null, null, PHAR::ZIP);
     $phar->buildFromDirectory($from);
     $phar->compressFiles(PHAR::GZ);
     unset($phar);
     if (!file_exists($to)) {
         throw new Exception('Can\'t create zip file');
     }
     if (PHP_SAPI == 'cli') {
         echo "Zip file is created\n";
     }
 }
开发者ID:quan-vu,项目名称:crxbuild,代码行数:20,代码来源:CrxBuild.php

示例11: unlink

 function __c3_build_html_report(PHP_CodeCoverage $codeCoverage, $path)
 {
     $writer = new PHP_CodeCoverage_Report_HTML();
     $writer->process($codeCoverage, $path . 'html');
     if (file_exists($path . '.tar')) {
         unlink($path . '.tar');
     }
     $phar = new PharData($path . '.tar');
     $phar->setSignatureAlgorithm(Phar::SHA1);
     $files = $phar->buildFromDirectory($path . 'html');
     array_map('unlink', $files);
     if (in_array('GZ', Phar::getSupportedCompression())) {
         if (file_exists($path . '.tar.gz')) {
             unlink($path . '.tar.gz');
         }
         $phar->compress(\Phar::GZ);
         // close the file so that we can rename it
         unset($phar);
         unlink($path . '.tar');
         rename($path . '.tar.gz', $path . '.tar');
     }
     return $path . '.tar';
 }
开发者ID:lenninsanchez,项目名称:donadores,代码行数:23,代码来源:c3.php

示例12: compressTarGZ

function compressTarGZ($tar_filename, $tar_dir, $compress_level = 5)
{
    $compress_level = $compress_level < 1 || $compress_level > 9 ? 5 : $compress_level;
    $exit_code = 0;
    if (pathinfo($tar_filename, PATHINFO_EXTENSION) == 'gz') {
        $filename = rtrim($tar_filename, '.gz');
    } else {
        $filename = $tar_filename . '.tar.gz';
    }
    $tar = rtrim($tar_filename, '.gz');
    //remove archive if exists
    if (is_file($tar_filename)) {
        unlink($tar_filename);
    }
    if (is_file($filename)) {
        unlink($filename);
    }
    if (is_file($tar)) {
        unlink($tar);
    }
    if (class_exists('PharData')) {
        try {
            $a = new PharData($tar);
            $a->buildFromDirectory($tar_dir);
            // this code creates tar-file
            if (file_exists($tar)) {
                // remove tar-file after zipping
                gzip($tar, $compress_level);
                unlink($tar);
            }
        } catch (Exception $e) {
            $error = new AError($e->getMessage());
            $error->toLog()->toDebug();
            $exit_code = 1;
        }
    } else {
        $exit_code = 1;
    }
    if ($exit_code) {
        $registry = Registry::getInstance();
        $registry->get('load')->library('targz');
        $targz = new Atargz();
        return $targz->makeTar($tar_dir . $tar_filename, $filename, $compress_level);
    } else {
        return true;
    }
}
开发者ID:InquisitiveQuail,项目名称:abantecart-src,代码行数:47,代码来源:utils.php

示例13: packFiles

/**
 * Pack files
 * 
 * @param type $files
 * @param type $compress
 */
function packFiles($files = null, $compress = false)
{
    try {
        // We remove the old archive
        if (is_file('netbeans.tar')) {
            unlink('netbeans.tar');
        }
        $phar = new PharData('netbeans.tar');
        if ($files) {
            // We only pack the specified files
        } else {
            // We pack the whole directory
            $phar->buildFromDirectory('netbeans');
        }
        if ($compress) {
            $phar->compress(Phar::GZ);
        }
    } catch (Exception $e) {
        echo "Exception : " . $e;
    }
}
开发者ID:radicaldingos,项目名称:netbeans-repository-generator,代码行数:27,代码来源:functions.php

示例14: addFiles

 /**
  * Adding files to the archive.
  *
  * @param PharData|ZipArchive $archive
  * @return PharData|ZipArchive
  * @access private
  * @final
  */
 private final function addFiles($archive)
 {
     switch ($this->type) {
         case self::RAR:
         case self::TAR:
             $archive->buildFromDirectory($this->path);
             break;
         case self::ZIP:
             $this->backupDir = str_replace('\\', '/', realpath($this->path));
             $files = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($this->path), RecursiveIteratorIterator::SELF_FIRST);
             foreach ($files as $file) {
                 $file = str_replace('\\', '/', $file);
                 if (in_array(substr($file, strrpos($file, '/') + 1), array('.', '..'))) {
                     continue;
                 }
                 $file = realpath($file);
                 if (is_file($file)) {
                     $archive->addFile($file, trim(str_replace($this->path, '', $file), '/'));
                 }
             }
             break;
     }
     return $archive;
 }
开发者ID:anykey84,项目名称:davbackup,代码行数:32,代码来源:DavBackup.php

示例15: testTarRequest

 /**
  * @depends testConnect
  */
 public function testTarRequest(ApiClient $docker)
 {
     mkdir('/project/TEMP');
     $tarFilename = sys_get_temp_dir() . '/' . uniqid() . '.tar';
     $phar = new \PharData($tarFilename);
     $phar->buildFromDirectory('/project/containers/php');
     $response = $docker->put('/containers/' . getenv('HOSTNAME') . '/archive', ['path' => '/project/TEMP'], new requestHandlers\Tar($tarFilename));
     $this->assertEquals(200, $response->getStatus());
     $this->assertFileExists('/project/TEMP/Dockerfile');
     unlink($tarFilename);
     exec('rm -rf /project/TEMP');
 }
开发者ID:jarkt,项目名称:docker-php-client,代码行数:15,代码来源:ApiClientTest.php


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