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


PHP Phar::isFileFormat方法代码示例

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


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

示例1: catch

 function __construct($base, $outdirectory = null)
 {
     try {
         $p = new \PharData($base);
     } catch (\Exception $e) {
         try {
             $p = new \Phar($base);
         } catch (\Exception $ee) {
             throw $e;
         }
     }
     $this->phar = $p;
     if ($p->isFileFormat(\Phar::PHAR)) {
         $this->phar = $p;
     } elseif ($p->isFileFormat(\Phar::TAR) && !$p->isCompressed()) {
         $this->tar = $p;
     } elseif ($p->isFileFormat(\Phar::ZIP)) {
         $this->zip = $p;
     }
     $sig = $p->getSignature();
     if ($sig) {
         $this->hash = $sig['hash'];
         $this->signature_algo = $sig['hash_type'];
     }
     $info = pathinfo($base);
     $this->file = $info['dirname'] . DIRECTORY_SEPARATOR . $info['filename'];
     $this->ext = substr($info['filename'], strpos($info['filename'], '.'));
     if ($outdirectory) {
         $this->outfile = realpath($outdirectory) . DIRECTORY_SEPARATOR . $info['filename'];
         copy($base, $this->outfile . '.' . $info['extension']);
     }
 }
开发者ID:peopleplan,项目名称:Pyrus,代码行数:32,代码来源:Cloner.php

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

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

示例4: dirname

<?php

$fname = dirname(__FILE__) . '/phar_gzip.phar';
$pname = 'phar://' . $fname;
$fname2 = dirname(__FILE__) . '/phar_gzip.2.phar';
$pname2 = 'phar://' . $fname2;
$file = '<?php
Phar::mapPhar();
var_dump("it worked");
include "phar://" . __FILE__ . "/tar_004.php";
__HALT_COMPILER();';
$files = array();
$files['tar_004.php'] = '<?php var_dump(__FILE__);';
$files['internal/file/here'] = "hi there!\n";
$files['internal/dir/'] = '';
$files['dir/'] = '';
$gzip = true;
include 'files/phar_test.inc';
include $fname;
$a = new Phar($fname);
$a['test'] = 'hi';
copy($fname, $fname2);
$a->setAlias('another');
$b = new Phar($fname2);
var_dump($b->isFileFormat(Phar::PHAR));
var_dump($b->isCompressed() == Phar::GZ);
?>
===DONE===
开发者ID:gleamingthecube,项目名称:php,代码行数:28,代码来源:ext_phar_tests_phar_gzipU.php

示例5: dirname

$pname = 'phar://' . $fname;
$fname2 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.tar.gz';
$fname3 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.2.phar.tar';
$stub = '<?php echo "first stub\\n"; __HALT_COMPILER(); ?>';
$file = $stub;
$files = array();
$files['a'] = 'a';
$files['b'] = 'b';
$files['c'] = 'c';
include 'files/phar_test.inc';
$phar = new Phar($fname);
var_dump($phar->isFileFormat(Phar::TAR));
var_dump($phar->isCompressed());
var_dump($phar->getStub());
$phar = $phar->convertToExecutable(Phar::TAR, Phar::GZ);
var_dump($phar->isFileFormat(Phar::TAR));
var_dump($phar->isCompressed());
var_dump($phar->getStub());
copy($fname2, $fname3);
$phar = new Phar($fname3);
var_dump($phar->isFileFormat(Phar::TAR));
var_dump($phar->isCompressed() == Phar::GZ);
var_dump($phar->getStub());
?>
===DONE===
<?php 
error_reporting(0);
unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.tar.gz');
unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.tar');
unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.2.phar.tar');
unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php');
开发者ID:badlamer,项目名称:hhvm,代码行数:31,代码来源:phar_convert_tar2.php

示例6: dirname

<?php

$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar';
$pname = 'phar://' . $fname;
$fname2 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.zip';
$fname3 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.2.phar.zip';
$stub = '<?php echo "first stub\\n"; __HALT_COMPILER(); ?>';
$file = $stub;
$files = array();
$files['a'] = 'a';
$files['b'] = 'b';
$files['c'] = 'c';
include 'files/phar_test.inc';
$phar = new Phar($fname);
var_dump($phar->isFileFormat(Phar::ZIP));
var_dump($phar->getStub());
$phar = $phar->convertToExecutable(Phar::ZIP);
var_dump($phar->isFileFormat(Phar::ZIP));
var_dump($phar->getStub());
copy($fname2, $fname3);
$phar = new Phar($fname3);
var_dump($phar->isFileFormat(Phar::ZIP));
var_dump($phar->getStub());
?>
===DONE===
开发者ID:gleamingthecube,项目名称:php,代码行数:25,代码来源:ext_phar_tests_phar_convert_zip.php

示例7: dirname

<?php

$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar';
$pname = 'phar://' . $fname;
$fname2 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.zip';
$fname3 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.tar';
$stub = '<?php echo "first stub\\n"; __HALT_COMPILER(); ?>';
$file = $stub;
$files = array();
$files['a'] = 'a';
$files['b'] = 'b';
$files['c'] = 'c';
include 'files/phar_test.inc';
echo "=================== new Phar() =======================\n";
$phar = new Phar($fname);
var_dump($phar->isFileFormat(Phar::PHAR));
var_dump($phar->isFileFormat(Phar::TAR));
var_dump($phar->isFileFormat(Phar::ZIP));
var_dump($phar->getStub());
var_dump($phar->getAlias());
echo "================= convertToTar() =====================\n";
$phar = $phar->convertToExecutable(Phar::TAR);
var_dump($phar->isFileFormat(Phar::PHAR));
var_dump($phar->isFileFormat(Phar::TAR));
var_dump($phar->isFileFormat(Phar::ZIP));
var_dump($phar->getStub());
var_dump($phar->getAlias());
echo "================= convertToZip() =====================\n";
$phar = $phar->convertToExecutable(Phar::ZIP);
var_dump($phar->isFileFormat(Phar::PHAR));
var_dump($phar->isFileFormat(Phar::TAR));
开发者ID:zaky-92,项目名称:php-1,代码行数:31,代码来源:ext_phar_tests_phar_convert_repeated.php

示例8: array

$pname2 = 'phar://' . $fname2;
$file = '<?php
Phar::mapPhar();
var_dump("it worked");
include "phar://" . __FILE__ . "/tar_004.php";
__HALT_COMPILER();';
$files = array();
$files['tar_004.php'] = '<?php var_dump(__FILE__);';
$files['internal/file/here'] = "hi there!\n";
$files['internal/dir/'] = '';
$files['dir/'] = '';
$bz2 = true;
include 'files/phar_test.inc';
include $fname;
$a = new Phar($fname);
$a['test'] = 'hi';
copy($fname, $fname2);
$a->setAlias('another');
$b = new Phar($fname2);
var_dump($b->isFileFormat(Phar::PHAR));
var_dump($b->isCompressed() == Phar::BZ2);
// additional code coverage
$b->isFileFormat(array());
try {
    $b->isFileFormat(25);
} catch (Exception $e) {
    echo $e->getMessage(), "\n";
}
?>
===DONE===
开发者ID:zaky-92,项目名称:php-1,代码行数:30,代码来源:ext_phar_tests_phar_bz2.php

示例9: Phar

 * Tar with extension of regular Phar
 */
echo "\n.phar (which is .phar.tar):\n";
$p = new Phar(__DIR__ . "/basic-tar.phar");
var_dump('is phar', $p->isFileFormat(Phar::PHAR));
var_dump('is tar', $p->isFileFormat(Phar::TAR));
var_dump('is zip', $p->isFileFormat(Phar::ZIP));
/**
 * Tar GZ with extension of regular Phar
 */
echo "\n.phar (which is .phar.tar.gz):\n";
$p = new Phar(__DIR__ . "/basic-tar-gz.phar");
var_dump('is phar', $p->isFileFormat(Phar::PHAR));
var_dump('is tar', $p->isFileFormat(Phar::TAR));
var_dump('is zip', $p->isFileFormat(Phar::ZIP));
/**
 * Tar BZ2 with extension of regular Phar
 */
echo "\n.phar (which is .phar.tar.bz2):\n";
$p = new Phar(__DIR__ . "/basic-tar-bz2.phar");
var_dump('is phar', $p->isFileFormat(Phar::PHAR));
var_dump('is tar', $p->isFileFormat(Phar::TAR));
var_dump('is zip', $p->isFileFormat(Phar::ZIP));
/**
 * Zip with extension of regular Phar
 */
echo "\n.phar (which is .phar.zip):\n";
$p = new Phar(__DIR__ . "/basic-zip.phar");
var_dump('is phar', $p->isFileFormat(Phar::PHAR));
var_dump('is tar', $p->isFileFormat(Phar::TAR));
var_dump('is zip', $p->isFileFormat(Phar::ZIP));
开发者ID:sskblr,项目名称:hhvm,代码行数:31,代码来源:is_file_format.php


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