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


PHP Phar::extractTo方法代码示例

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


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

示例1: extractResources

 /**
  * Extract resources to a file system path
  * 
  * @param Phar $phar Phar archive.
  * @param string $path Output path root.
  */
 protected function extractResources(Phar $phar, $path)
 {
     $this->deleteDirectory($path);
     $phar->extractTo($path);
     @unlink($path . '/index.php');
     @unlink($path . '/build.bat');
     $this->copyDirectory($path . '/resources', $path, false);
     $this->deleteDirectory($path . '/resources');
 }
开发者ID:arendasistemasintegrados,项目名称:mateusleme,代码行数:15,代码来源:PackageScaffolderAbstract.php

示例2: extract

 /**
  * {@inheritDoc}
  */
 protected function extract($file, $path)
 {
     // Can throw an UnexpectedValueException
     $archive = new \Phar($file);
     $archive->extractTo($path, null, true);
     /* TODO: handle openssl signed phars
      * https://github.com/composer/composer/pull/33#issuecomment-2250768
      * https://github.com/koto/phar-util
      * http://blog.kotowicz.net/2010/08/hardening-php-how-to-securely-include.html
      */
 }
开发者ID:alancleaver,项目名称:composer,代码行数:14,代码来源:PharDownloader.php

示例3: install

function install($rootFolder)
{
    out('Installing');
    chdir("{$rootFolder}/");
    $phar = new Phar("{$rootFolder}/dashboard.phar");
    $phar->extractTo("{$rootFolder}/tmp/", null, true);
    system("mv {$rootFolder}/tmp/src/Hoborg/Dashboard/Resources/htdocs/index-phar.php {$rootFolder}/htdocs/index.php");
    system("mv {$rootFolder}/tmp/src/Hoborg/Dashboard/Resources/htdocs/static {$rootFolder}/htdocs/static");
    system("mv {$rootFolder}/tmp/src/Hoborg/Dashboard/Resources/htdocs/images {$rootFolder}/htdocs/images");
    system("rm -rf {$rootFolder}/tmp");
    return true;
}
开发者ID:hoborglabs,项目名称:dashboard,代码行数:12,代码来源:install.php

示例4: extract

 /**
  * {@inheritdoc}
  */
 public function extract($file, $target, Format\FormatInterface $format)
 {
     $this->checkSupport($format);
     try {
         $phar = new \Phar($file);
         $this->getFilesystem()->mkdir($target);
         $phar->extractTo($target, null, true);
         return true;
     } catch (\Exception $e) {
         throw new FileCorruptedException($file);
     }
 }
开发者ID:hassiumsoft,项目名称:hasscms-app-vendor,代码行数:15,代码来源:Phar.php

示例5: extractComposer

function extractComposer()
{
    if (file_exists('composer.phar')) {
        echo 'Extracting composer.phar ...' . PHP_EOL;
        flush();
        $composer = new Phar('composer.phar');
        $composer->extractTo('extracted');
        echo 'Extraction complete.' . PHP_EOL;
    } else {
        echo 'composer.phar does not exist';
    }
}
开发者ID:Contao-DD,项目名称:NoConsoleComposer,代码行数:12,代码来源:main.php

示例6: execute

 /**
  * Executes the current command.
  *
  * @param InputInterface  $input  An InputInterface instance
  * @param OutputInterface $output An OutputInterface instance
  *
  * @return null|int     null or 0 if everything went fine, or an error code
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $output->writeln('');
     $output->writeln('<comment>Extracting package</comment>');
     $this->validate($input, $output);
     $extractIn = $input->getOption('output');
     $rutaPhar = $input->getOption('phar');
     // $dir = Phar::running(false);
     $p = new \Phar($rutaPhar);
     $p->extractTo($extractIn, null, true);
     $output->writeln('');
     $output->writeln("<info>Phar extracted in </info>" . $extractIn);
 }
开发者ID:mostofreddy,项目名称:phox,代码行数:21,代码来源:Extract.php

示例7: installComposer

 public static function installComposer()
 {
     if (!file_exists('composer/bin/composer')) {
         Tools::createDir('composer');
         if (!file_exists('composer/composer.phar')) {
             file_put_contents('composer/composerInstall.php', file_get_contents('https://getcomposer.org/installer'));
             $argv = ['install', '--install-dir', 'composer/'];
             header("Location: " . filter_input(INPUT_SERVER, 'REQUEST_URI'));
             include_once 'composer/composerInstall.php';
         }
         $composer = new Phar('composer/composer.phar');
         $composer->extractTo('composer/');
     }
 }
开发者ID:krvd,项目名称:cms-Inji,代码行数:14,代码来源:ComposerCmd.php

示例8: extractFile

 /**
  * Extract the file from the phar archive to make it accessible for native commands.
  *
  * @param string $filePath  the absolute file path to extract
  * @param bool   $overwrite
  *
  * @return string
  */
 public static function extractFile($filePath, $overwrite = false)
 {
     $pharPath = \Phar::running(false);
     if (empty($pharPath)) {
         return '';
     }
     $relativeFilePath = substr($filePath, strpos($filePath, $pharPath) + strlen($pharPath) + 1);
     $tmpDir = sys_get_temp_dir() . '/jolinotif';
     $extractedFilePath = $tmpDir . '/' . $relativeFilePath;
     if (!file_exists($extractedFilePath) || $overwrite) {
         $phar = new \Phar($pharPath);
         $phar->extractTo($tmpDir, $relativeFilePath, $overwrite);
     }
     return $extractedFilePath;
 }
开发者ID:jeremyFreeAgent,项目名称:JoliNotif,代码行数:23,代码来源:PharExtractor.php

示例9: install

 /**
  * Install an updated version of a cabin
  *
  * If we get to this point:
  *
  * 1. We know the signature is signed by the supplier.
  * 2. The hash was checked into Keyggdrasil, which
  *    was independently vouched for by our peers.
  *
  * @param UpdateInfo $info
  * @param UpdateFile $file
  * @throws CouldNotUpdate
  */
 protected function install(UpdateInfo $info, UpdateFile $file)
 {
     if (!$file->hashMatches($info->getChecksum())) {
         throw new CouldNotUpdate(\__('Checksum mismatched'));
     }
     $path = $file->getPath();
     $this->log('Begin Cabin updater', LogLevel::DEBUG, ['path' => $path, 'supplier' => $info->getSupplierName(), 'name' => $info->getPackageName()]);
     $updater = new \Phar($path, \FilesystemIterator::CURRENT_AS_FILEINFO | \FilesystemIterator::KEY_AS_FILENAME);
     $updater->setAlias($this->pharAlias);
     $ns = $this->makeNamespace($info->getSupplierName(), $info->getPackageName());
     // We need to do this while we're replacing files.
     $this->bringCabinDown($ns);
     $oldMetadata = \Airship\loadJSON(ROOT . '/Cabin/' . $ns . '/manifest.json');
     // Overwrite files
     $updater->extractTo(ROOT . '/Cabin/' . $ns, null, true);
     // Run the update trigger.
     Sandbox::safeInclude('phar://' . $this->pharAlias . '/update_trigger.php', $oldMetadata);
     // Free up the updater alias
     $garbageAlias = Base64UrlSafe::encode(\random_bytes(33)) . '.phar';
     $updater->setAlias($garbageAlias);
     unset($updater);
     // Now bring it back up.
     $this->bringCabinBackUp($ns);
     // Make sure we update the version info. in the DB cache:
     $this->updateDBRecord('Cabin', $info);
     $this->log('Conclude Cabin updater', LogLevel::DEBUG, ['path' => $path, 'supplier' => $info->getSupplierName(), 'name' => $info->getPackageName()]);
     self::$continuumLogger->store(LogLevel::INFO, 'Cabin update installed', $this->getLogContext($info, $file));
 }
开发者ID:paragonie,项目名称:airship,代码行数:41,代码来源:Cabin.php

示例10: Phar

#!/usr/bin/env php
<?php 
$phar = new Phar($argv[1]);
$phar->extractTo($argv[2]);
开发者ID:Jadoube-Initiative,项目名称:phpPGN,代码行数:4,代码来源:extractPhar.php

示例11: extractPharFile

 public function extractPharFile()
 {
     $phar = new \Phar(\Yii::getAlias('@tests/_runtime/yii2-phar/app.phar'));
     $phar->extractTo(\Yii::getAlias('@tests/_runtime/yii2-phar/extract'));
 }
开发者ID:index0h,项目名称:yii2-phar,代码行数:5,代码来源:CodeHelper.php

示例12: realpath

<?php

define('EXTRACT_DIRECTORY', realpath("../../"));
if (file_exists(EXTRACT_DIRECTORY . '/vendor/autoload.php') == true) {
    echo "Extracted autoload already exists. Skipping phar extraction as presumably it's already extracted.";
} else {
    $composerPhar = new Phar("composer.phar");
    //php.ini setting phar.readonly must be set to 0
    $composerPhar->extractTo(EXTRACT_DIRECTORY . '/vendor/');
}
//This requires the phar to have been extracted successfully.
require_once EXTRACT_DIRECTORY . '/vendor/vendor/autoload.php';
//Use the Composer classes
use Composer\Console\Application;
use Composer\Command\UpdateCommand;
use Symfony\Component\Console\Input\ArrayInput;
// change out of the webroot so that the vendors file is not created in
// a place that will be visible to the intahwebz
chdir('../');
//Create the commands
$input = new ArrayInput(array('command' => 'install'));
//Create the application and run it with the commands
$application = new Application();
$application->run($input);
开发者ID:Trax2k,项目名称:hostkit,代码行数:24,代码来源:composerExtractor.php

示例13: dirname

<?php

$fname = dirname(__FILE__) . '/tempmanifest2.phar.php';
$pname = 'phar://' . $fname;
$phar = new Phar($fname);
$phar->setDefaultStub();
$phar->setAlias('fred');
$phar['file1.txt'] = 'hi';
$phar['file2.txt'] = 'hi2';
$phar['subdir/ectory/file.txt'] = 'hi3';
$phar->mount($pname . '/mount2', __FILE__);
$phar->addEmptyDir('one/level');
$phar->extractTo(dirname(__FILE__) . '/extract2', 'mount2');
$phar->extractTo(dirname(__FILE__) . '/extract2');
$out = array();
foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator(dirname(__FILE__) . '/extract2', 0x3000), RecursiveIteratorIterator::CHILD_FIRST) as $path => $file) {
    $extracted[] = $path;
}
sort($extracted);
foreach ($extracted as $out) {
    echo "{$out}\n";
}
?>
===DONE===
<?php 
@unlink(dirname(__FILE__) . '/tempmanifest2.phar.php');
$dir = dirname(__FILE__) . '/extract2/';
@unlink($dir . 'file1.txt');
@unlink($dir . 'file2.txt');
@unlink($dir . 'subdir/ectory/file.txt');
@rmdir($dir . 'subdir/ectory');
开发者ID:alphaxxl,项目名称:hhvm,代码行数:31,代码来源:phar_extract2.php

示例14: unlink

             echo -2;
         }
         // Suppression du fichier
         unlink($lNomFichier);
     } else {
         echo 0;
     }
     break;
 case 4:
     // Déploiement du zeybux
     // vider le dossier d'extraction
     viderDossier(DOSSIER_EXTRACT, 1);
     // Création du phar
     $p = new Phar("./" . DOSSIER_UPLOAD . "/" . $_POST["phar"]);
     // Extraction de l'archive
     $p->extractTo(DOSSIER_EXTRACT);
     // Supression de l'ancien site excepté dossier maintenance, index.php, dossier configuration et Maintenance.php du dossier configuration
     // Pas de suppression des logs
     function supprimerDossier($pPath)
     {
         $d = dir($pPath);
         while (false !== ($entry = $d->read())) {
             if ($entry != '.' && $entry != '..' && $d->path . '/' . $entry != '../index.html' && $entry != "DB.php" && $entry != "LogLevel.php" && $entry != "Mail.php" && $entry != 'Maintenance.php' && $entry != "Proprietaire.php" && $entry != 'SOAP.php' && $entry != 'Titre.php' && $entry != 'Maintenance' && $entry != 'logs' && $entry != ".htaccess") {
                 if (is_dir($d->path . '/' . $entry)) {
                     supprimerDossier($d->path . '/' . $entry);
                     if ($entry != 'configuration' && $entry != 'classes' && $entry != 'html' && $entry != 'vues') {
                         rmdir($d->path . '/' . $entry);
                     }
                 } else {
                     $filename = $d->path . '/' . $entry;
                     unlink($filename);
开发者ID:google-code-backups,项目名称:zeybux,代码行数:31,代码来源:maj.php

示例15: dirname

<?php

$fname = dirname(__FILE__) . '/tempmanifest1.phar.php';
$pname = 'phar://' . $fname;
$a = new Phar($fname);
$a['file1.txt'] = 'hi';
$a['file2.txt'] = 'hi2';
$a['subdir/ectory/file.txt'] = 'hi3';
$a->mount($pname . '/mount', __FILE__);
$a->addEmptyDir('one/level');
$a->extractTo(dirname(__FILE__) . '/extract', 'mount');
$a->extractTo(dirname(__FILE__) . '/extract');
$out = array();
foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator(dirname(__FILE__) . '/extract', 0x3000), RecursiveIteratorIterator::CHILD_FIRST) as $p => $b) {
    $out[] = $p;
}
sort($out);
foreach ($out as $b) {
    echo "{$b}\n";
}
$a->extractTo(dirname(__FILE__) . '/extract1', 'file1.txt');
var_dump(file_get_contents(dirname(__FILE__) . '/extract1/file1.txt'));
$a->extractTo(dirname(__FILE__) . '/extract1', 'subdir/ectory/file.txt');
var_dump(file_get_contents(dirname(__FILE__) . '/extract1/subdir/ectory/file.txt'));
$a->extractTo(dirname(__FILE__) . '/extract1-2', array('file2.txt', 'one/level'));
var_dump(file_get_contents(dirname(__FILE__) . '/extract1-2/file2.txt'));
var_dump(is_dir(dirname(__FILE__) . '/extract1-2/one/level'));
try {
    $a->extractTo(dirname(__FILE__) . '/whatever', 134);
} catch (Exception $e) {
    echo $e->getMessage(), "\n";
开发者ID:zaky-92,项目名称:php-1,代码行数:31,代码来源:ext_phar_tests_phar_extract.php


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