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


PHP Phar::unlinkArchive方法代码示例

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


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

示例1: 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

示例2: testExtractFileOverwritesExistingFileIfSpecified

 public function testExtractFileOverwritesExistingFileIfSpecified()
 {
     $key = uniqid();
     $pharPath = $this->getTestDir() . '/phar-extractor-overwrite-' . $key . '.phar';
     $relativeFilePath = 'path/to/file-' . $key . '.txt';
     $extractedFilePath = sys_get_temp_dir() . '/jolinotif/' . $relativeFilePath;
     $this->generatePhar($pharPath, $relativeFilePath, $key, false);
     $this->assertTrue(is_file($pharPath));
     exec('php ' . $pharPath);
     \Phar::unlinkArchive($pharPath);
     $this->generatePhar($pharPath, $relativeFilePath, 'new content', true);
     $this->assertTrue(is_file($pharPath));
     exec('php ' . $pharPath);
     \Phar::unlinkArchive($pharPath);
     $this->assertTrue(is_file($extractedFilePath));
     $this->assertSame('new content', file_get_contents($extractedFilePath));
     unlink($extractedFilePath);
 }
开发者ID:jolicode,项目名称:jolinotif,代码行数:18,代码来源:PharExtractorTest.php

示例3: unpack_tar

function unpack_tar($path)
{
    $response = new Response();
    //echo "Unpack.\n";
    //echo "path:".$path;
    /*
     system("mkdir archiv/name");
     system("cp upload/FosCam9805.tar.gz archiv/name/FosCam9805.tar.gz");
     system("mkdir archiv/name/temp");
     //system("tar -xvzf archiv/name/FosCam9805.tar.gz -C archiv/name/temp/");
    */
    // This input should be from somewhere else, hard-coded in this example
    $file_name = $path;
    // Raising this value may increase performance
    $buffer_size = 4096;
    // read 4kb at a time
    $out_file_name = str_replace('.gz', '', $file_name);
    // Open our files (in binary mode)
    $file = gzopen($file_name, 'rb');
    $out_file = fopen($out_file_name, 'wb');
    // Keep repeating until the end of the input file
    while (!gzeof($file)) {
        // Read buffer-size bytes
        // Both fwrite and gzread and binary-safe
        fwrite($out_file, gzread($file, $buffer_size));
    }
    // Files are done, close files
    fclose($out_file);
    gzclose($file);
    //var_dump($out_file_name);
    //return;
    $phar_data = new PharData($out_file_name);
    $phar_data->extractTo(str_replace(".tar", "", $out_file_name));
    //unlink($out_file_name);
    unset($phar_data);
    Phar::unlinkArchive($out_file_name);
    //echo "finish unpacking archive<br>";
}
开发者ID:zwave-mke,项目名称:developer-console,代码行数:38,代码来源:functions.php

示例4: pack

    public function pack()
    {
        if (file_exists(self::NAME)) {
            \Phar::unlinkArchive(self::NAME);
        }
        $phar = new \Phar(self::NAME);
        // Stub
        $code = <<<'EOC'
#! /usr/bin/env php
<?php

Phar::mapPhar('phpmig.phar');

define('PHPMIG_PHAR', true);
require 'phar://phpmig.phar/vendor/autoload.php';
$app = new PhpMigration\App();
$app->run();

__HALT_COMPILER();
EOC;
        $phar->setStub($code);
        // File
        foreach ($this->filelist as $file) {
            $phar->addFile($file);
        }
        // Vendor
        chdir(__DIR__ . '/../../');
        $iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator('vendor'), 0, \RecursiveIteratorIterator::CATCH_GET_CHILD);
        foreach ($iterator as $file) {
            if (!preg_match('/\\/(\\.|test\\/)/i', $file)) {
                $phar->addFile($file);
            }
        }
        // Add execute permission
        chmod(self::NAME, 0755);
    }
开发者ID:monque,项目名称:php-migration,代码行数:36,代码来源:Packager.php

示例5: chdir

<?php

chdir(dirname(__DIR__));
$binary = $argv[1];
$scriptFilename = "scripts/{$binary}.php";
$pharFilename = "bin/{$binary}.phar";
$binaryFilename = "bin/{$binary}";
if (file_exists($pharFilename)) {
    Phar::unlinkArchive($pharFilename);
}
if (file_exists($binaryFilename)) {
    Phar::unlinkArchive($binaryFilename);
}
$phar = new Phar($pharFilename, FilesystemIterator::KEY_AS_PATHNAME | FilesystemIterator::CURRENT_AS_FILEINFO, $binary);
$phar->startBuffering();
$directories = array('src', 'vendor', 'scripts');
foreach ($directories as $dirname) {
    $iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dirname));
    while ($iterator->valid()) {
        if ($iterator->isFile()) {
            $path = $iterator->getPathName();
            if ('php' == strtolower($iterator->getExtension())) {
                $contents = php_strip_whitespace($path);
                $phar->addFromString($path, $contents);
            } else {
                $phar->addFile($path);
            }
        }
        $iterator->next();
    }
}
开发者ID:gamegos,项目名称:php-code-sniffer,代码行数:31,代码来源:create-phar.php

示例6: Phar

<?php

// Cleanup
if (file_exists(__DIR__ . 'ThriftSQL.phar')) {
    Phar::unlinkArchive(__DIR__ . 'ThriftSQL.phar');
}
// Create Stub
$stub = <<<EOF
<?php
  include 'phar://' . __FILE__ . '/autoload.php';
  __HALT_COMPILER();
EOF;
// Create Phar
$phar = new Phar('ThriftSQL.phar', null, 'ThriftSQL.phar');
$phar->buildFromDirectory(__DIR__ . '/src');
$phar->setStub($stub);
开发者ID:Napas,项目名称:php-thrift-sql,代码行数:16,代码来源:build.php

示例7: 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>Creating package</comment>');
     $this->validate($input, $output);
     try {
         //get all params
         $rutaPhar = $input->getOption('output');
         $alias = $input->getOption('alias') . '.phar';
         $rutaPhar = rtrim($rutaPhar, '/') . '/' . $alias;
         $src = $input->getOption('src');
         $stub = $input->getOption('stub');
         $stubweb = $input->getOption('stubweb');
         $replace = $input->getOption('replace');
         $exclude = $input->getOption('exclude');
         if (true === $replace && is_file($rutaPhar)) {
             \Phar::unlinkArchive($rutaPhar);
         }
         //create and setup Stup object
         $oStub = new Stub();
         if (null !== $stub) {
             $oStub->setStubCli($stub);
         }
         if (null !== $stubweb) {
             $oStub->setStubWeb($stubweb);
         }
         $oStub->setDirTmp($src);
         $oStub->createDefaultStub();
         //create Finder object
         $finder = new Finder();
         $finder->files()->in($src);
         foreach ($exclude as $dirToExclude) {
             $finder->exclude($dirToExclude);
         }
         //inicialize progressbar
         $progress = new ProgressBar($output, count($finder));
         //create phar object
         $phar = new \Phar($rutaPhar, 0, $alias);
         $phar->startBuffering();
         //create default stubs
         $phar->setStub($phar->createDefaultStub($oStub->getStubCli(), $oStub->getStubWeb()));
         $progress->setBarCharacter('<comment>=</comment>');
         $progress->setProgressCharacter('<comment>></comment>');
         //add all files in the phar object
         $progress->start();
         foreach ($finder as $file) {
             $alias = ltrim(str_replace($src, '', $file->getPathname()), '/');
             $phar->addFile($file, $alias);
             $progress->advance();
         }
         $progress->finish();
         $phar->stopBuffering();
         $oStub->deleteTmpStubs();
         $output->writeln('');
         $output->writeln('');
         $output->writeln("<info>Phar created in: </info>" . $rutaPhar);
     } catch (\Exception $e) {
         $output->writeln('<error>' . $e->getMessage() . "</error>");
         exit(1);
     }
 }
开发者ID:mostofreddy,项目名称:phox,代码行数:69,代码来源:Building.php

示例8: toPhar

 function toPhar()
 {
     if (isset($this->phar)) {
         return;
     }
     if (file_exists($this->file . '.phar')) {
         try {
             $p = new \Phar($this->file . '.phar');
         } catch (\Exception $e) {
         }
         if ($p->getSignature() === $this->phar->getSignature()) {
             $this->phar = $p;
             if ($this->outfile) {
                 copy($this->file . '.phar', $this->outfile . '.phar');
             }
             return;
         }
         unset($p);
         \Phar::unlinkArchive($this->file . '.phar');
     }
     if (isset($this->tar)) {
         if ($this->signature_algo == \Phar::OPENSSL) {
             throw new Exception('Cannot create tar archive, signature is OpenSSL, ' . 'you must directly create it using the package command');
         }
         if (file_exists($this->file . '.phar')) {
             \Phar::unlinkArchive($this->file . '.phar');
             unlink($this->file . '.phar');
         }
         $this->phar = $this->tar->convertToExecutable(\Phar::PHAR, \Phar::NONE, $this->ext . '.phar');
         if ($this->outfile) {
             copy($this->file . '.phar', $this->outfile . '.phar');
         }
         $this->tar = new \PharData($this->file . '.tar');
         return;
     }
     if (isset($this->tgz)) {
         if ($this->signature_algo == \Phar::OPENSSL) {
             throw new Exception('Cannot create tar archive, signature is OpenSSL, ' . 'you must directly create it using the package command');
         }
         if (file_exists($this->file . '.phar')) {
             \Phar::unlinkArchive($this->file . '.phar');
             unlink($this->file . '.phar');
         }
         $this->phar = $this->tar->convertToExecutable(\Phar::PHAR, \Phar::NONE, $this->ext . '.phar');
         if ($this->outfile) {
             copy($this->file . '.phar', $this->outfile . '.phar');
         }
         $this->tgz = new \PharData($this->file . '.tgz');
         return;
     }
     // by process of elimination, the phar is in zip format
     if (file_exists($this->file . '.phar')) {
         \Phar::unlinkArchive($this->file . '.phar');
         unlink($this->file . '.phar');
     }
     $this->phar = $this->tar->convertToExecutable(\Phar::PHAR, \Phar::NONE, $this->ext . '.phar');
     if ($this->outfile) {
         copy($this->file . '.phar', $this->outfile . '.phar');
     }
     $this->zip = new \PharData($this->file . '.zip');
 }
开发者ID:peopleplan,项目名称:Pyrus,代码行数:61,代码来源:Cloner.php

示例9: displayhelp

    echo "ERROR: Source file location does not exist!\nCheck your source and try again.\n";
    displayhelp();
    die(1);
}
/*
* Let the user know what is going on
*/
echo "Creating PHAR\n";
echo "Source      : {$sourceLocation}\n";
echo "Destination : {$pharFile}\n";
echo "Stub File   : {$stubFile}\n\n";
/*
* Clean up from previous runs
*/
if (file_exists($pharFile)) {
    Phar::unlinkArchive($pharFile);
}
/*
* Setup the phar
*/
$p = new Phar($pharFile, 0, basename($pharFile));
$p->compressFiles(Phar::GZ);
$p->setSignatureAlgorithm(Phar::SHA1);
/*
* Now build the array of files to be in the phar.
* The first file is the stub file. The rest of the files are built from the directory.
*/
$files = array();
//$files["stub.php"] = $stubFile;
echo "Building the array of files to include.\n";
$rd = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($sourceLocation));
开发者ID:gossi,项目名称:webform,代码行数:31,代码来源:makephar.php

示例10: test_is_extension_changed

 /**
  * @covers common\classes\AutoLoader::is_extension_changed
  */
 public function test_is_extension_changed()
 {
     $method = new ReflectionMethod(AutoLoader::class, 'is_extension_changed');
     $method->setAccessible(true);
     self::assertFalse($method->invoke(null, 'tools'));
     $test_file = ROOT_PATH . DS . 'build' . DS . 'tools' . DS . 'test.php';
     if (file_exists('pfmextension://tools' . DS . 'test.php')) {
         unlink('pfmextension://tools' . DS . 'test.php');
     }
     file_put_contents($test_file, '');
     self::assertTrue($method->invoke(null, 'tools'));
     unlink($test_file);
     self::assertFalse($method->invoke(null, 'tools'));
     $tools_file = ROOT_PATH . DS . 'build' . DS . 'tools' . DS . 'tools.php';
     $old_data = file_get_contents($tools_file);
     file_put_contents($tools_file, '/*test comment*/', FILE_APPEND);
     self::assertTrue($method->invoke(null, 'tools'));
     file_put_contents($tools_file, $old_data);
     self::assertFalse($method->invoke(null, 'tools'));
     $extension_file = ROOT_PATH . DS . 'extensions' . DS . 'tools.tar.gz';
     Phar::unlinkArchive($extension_file);
     self::assertFalse($method->invoke(null, 'tools'));
     self::assertTrue(AutoLoader::load_extension('Tools'));
 }
开发者ID:one-more,项目名称:peach_framework,代码行数:27,代码来源:AutoloaderTest.php

示例11: unpack_zip

             unpack_zip($target_file);
             $target_file = str_replace('.zip', '.tar.gz', $target_file);
             $zip_file = pathinfo($_FILES["fileToUpload"]['name']);
             $tar_file = $target_dir . strtolower($zip_file['filename']);
             if (is_file($tar_file . '.tar.gz')) {
                 unlink($tar_file . '.tar.gz');
             }
             if (is_file($tar_file . '.zip')) {
                 unlink($tar_file . '.zip');
             }
             try {
                 $a = new PharData($tar_file . '.tar');
                 $a->buildFromDirectory($target_dir . strtolower($zip_file['filename']));
                 $a->compress(Phar::GZ);
                 unset($a);
                 Phar::unlinkArchive($tar_file . '.tar');
             } catch (Exception $e) {
                 $response->status = 500;
                 $response->message = $e->getMessage();
                 $response->json($response);
             }
         }
         $wrong_folder = current(explode(".", $_FILES["fileToUpload"]["name"]));
         //store data in DB
         $response = read_json($target_file, $id, 'gz', $wrong_folder);
     } else {
         $response->status = 500;
         $response->message = 'Sorry, your file was not uploaded.';
         $response->json($response);
     }
 }
开发者ID:zwave-mke,项目名称:developer-console,代码行数:31,代码来源:upload.php

示例12: sendTar

/**
 * Créé et télécharge une archive au format .tar.gz à partir d'un package et de ses dépendences.
 * Si erreur, renvoie JSON_FILE_SYSTEM_ERROR ou JSON_DOWNLOAD_ERROR et exit.
 *
 * @param string $filename Le nom de l'archive à créer/télécharger
 * @param Object $package Les infos du package (doit contenir les strings "name" et "version")
 * @param array[Object] $dependencies Les infos des dépendences (chaque entrée doit contenir les strings "name" et "version")
 */
function sendTar($filename, $package, $dependencies)
{
    $baseDir = createDirIfNotHere(dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . DIR_ALL);
    $packDir = createDirIfNotHere($baseDir . DIR_PACKAGE);
    $libDir = createDirIfNotHere($baseDir . DIR_LIB);
    $outDir = createDirIfNotHere($baseDir . DIR_OUT);
    $tempFile = $outDir . $filename . ".tar";
    try {
        $phar = new PharData($tempFile);
    } catch (UnexpectedValueException $e) {
        sendJson(JSON_FILE_SYSTEM_ERROR);
    }
    $packageToInclude = $packDir . $package["name"] . "-" . $package["version"];
    fillArchive($phar, $packageToInclude, $baseDir);
    foreach ($dependencies as $dependency) {
        $dependencyToInclude = $libDir . $dependency["name"] . "-" . $dependency["version"];
        fillArchive($phar, $dependencyToInclude, $baseDir);
    }
    $phar->compress(Phar::GZ);
    $fileToSend = $tempFile . ".gz";
    unset($phar);
    try {
        Phar::unlinkArchive($tempFile);
        // Suppression du fichier .tar
    } catch (PharException $e) {
        sendJson(JSON_FILE_SYSTEM_ERROR);
    }
    header('Content-Description: Archive Transfer');
    header('Content-Type: application/x-compressed');
    header('Content-Disposition: attachment; filename="' . basename($fileToSend) . '"');
    header('Expires: 0');
    header('Cache-Control: must-revalidate');
    header('Pragma: public');
    header('Content-Length: ' . filesize($fileToSend));
    if (!readfile($fileToSend)) {
        sendJson(JSON_DOWNLOAD_ERROR);
    }
    if (!unlink($fileToSend)) {
        // Suppression du fichier .gz
        die(JSON_FILE_SYSTEM_ERROR);
        // "die" obligatoire car on a déjà utilisé "readFile"
    }
    exit;
}
开发者ID:sl3-lyon,项目名称:OpenPM,代码行数:52,代码来源:functions.php

示例13: unlinkArchives

 protected function unlinkArchives()
 {
     unset($this->phar);
     $prefix = $this->runtime . DIRECTORY_SEPARATOR . 'example.phar';
     foreach (['', '.bz2', '.gz'] as $extension) {
         $path = $prefix . $extension;
         if (file_exists($path) === true) {
             \Phar::unlinkArchive($path);
         }
     }
     if (file_exists($this->runtime) === true) {
         FileHelper::removeDirectory($this->runtime);
     }
     mkdir($this->runtime, 0777, true);
 }
开发者ID:index0h,项目名称:yii2-phar,代码行数:15,代码来源:BuilderHelper.php

示例14:

<?php

Phar::unlinkArchive("/data/users/liranuna/fbcode/hphp/test/zend/bad/ext/phar/tests/phar_gobyebye.phar.php");
开发者ID:badlamer,项目名称:hhvm,代码行数:3,代码来源:phar_gobyebye.2.php

示例15: makePharPlugin

 public function makePharPlugin($pluginName)
 {
     if ($pluginName === "" or !($plugin = $this->getServer()->getPluginManager()->getPlugin($pluginName)) instanceof Plugin) {
         $this->getLogger()->alert("잘못된 플러그인 이름, 이름을 다시 확인해주세요");
         return;
     }
     $description = $plugin->getDescription();
     if (!$plugin->getPluginLoader() instanceof FolderPluginLoader) {
         $this->getLogger()->alert("플러그인 " . $description->getName() . " 은 이미 PHAR 상태입니다.");
         return;
     }
     $pharPath = $this->getServer()->getDataPath() . "localhost" . DIRECTORY_SEPARATOR . $pluginName . DIRECTORY_SEPARATOR . $description->getName() . "-release" . ".phar";
     if (file_exists($pharPath)) {
         $this->getLogger()->info("Phar 파일 덮어쓰기중...");
         \Phar::unlinkArchive($pharPath);
     }
     $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->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(array("\\", $filePath), array("/", ""), $file), "/");
         if ($path[0] === "." or strpos($path, "/.") !== false) {
             continue;
         }
         $phar->addFile($file, $path);
     }
     $phar->compressFiles(\Phar::GZ);
     $phar->stopBuffering();
     $this->getLogger()->info("PHAR이 해당 플러그인 소스폴더 안에 생성되었습니다. ");
     $this->getLogger()->info("( " . $pharPath . " )");
 }
开发者ID:organization,项目名称:Precompiler,代码行数:36,代码来源:Precompiler.php


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