本文整理汇总了PHP中Phar::isCompressed方法的典型用法代码示例。如果您正苦于以下问题:PHP Phar::isCompressed方法的具体用法?PHP Phar::isCompressed怎么用?PHP Phar::isCompressed使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Phar
的用法示例。
在下文中一共展示了Phar::isCompressed方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
/**
* @param bool $verbose
*/
function run($verbose = false)
{
if ($verbose) {
printf("Using stub '%s'...\n", basename($this->stub));
}
$stub = preg_replace_callback('/^#include <([^>]+)>/m', function ($includes) {
return file_get_contents($includes[1], true, null, 5);
}, file_get_contents($this->stub));
if ($this->phar->isCompressed() && substr($stub, 0, 2) === "#!") {
$stub = substr($stub, strpos($stub, "\n") + 1);
}
$this->phar->setStub($stub);
}
示例2: 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']);
}
}
示例3: 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===
示例4: dirname
<?php
$fname = dirname(__FILE__) . '/tar_makegz.phar.tar';
$fname2 = dirname(__FILE__) . '/tar_makegz.phar.tar.gz';
$fname3 = dirname(__FILE__) . '/tar_makegz_b.phar.tar.gz';
$phar = new Phar($fname);
$phar['test'] = 'hi';
var_dump($phar->isFileFormat(Phar::TAR));
$phar = $phar->compress(Phar::GZ);
copy($fname2, $fname3);
$phar2 = new Phar($fname3);
var_dump($phar2->isFileFormat(Phar::TAR));
var_dump($phar2->isCompressed() == Phar::GZ);
?>
===DONE===
示例5: dirname
<?php
$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
$fname2 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '2.phar.gz';
$pname = 'phar://' . $fname;
$file = '<?php __HALT_COMPILER(); ?>';
$files = array();
$files['a'] = 'a';
$files['b'] = 'b';
$files['c'] = 'c';
include 'files/phar_test.inc';
$phar = new Phar($fname);
$gz = $phar->compress(Phar::GZ);
copy($gz->getPath(), $fname2);
$a = new Phar($fname2);
var_dump($a->isCompressed());
$unc = $a->compress(Phar::NONE);
echo $unc->getPath() . "\n";
$unc2 = $gz->decompress();
echo $unc2->getPath() . "\n";
$unc3 = $gz->decompress('hooba.phar');
echo $unc3->getPath() . "\n";
$gz->decompress(array());
$zip = $phar->convertToData(Phar::ZIP);
ini_set('phar.readonly', 1);
try {
$gz->decompress();
} catch (Exception $e) {
echo $e->getMessage() . "\n";
}
try {
示例6: dirname
<?php
$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar';
$fname2 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '2.phar';
$phar = new Phar($fname);
$phar['a.txt'] = 'some text';
$phar->stopBuffering();
var_dump($phar->isFileFormat(Phar::TAR));
var_dump(strlen($phar->getStub()));
$phar = $phar->convertToExecutable(Phar::TAR);
var_dump($phar->isFileFormat(Phar::TAR));
var_dump($phar->getStub());
$phar['a'] = 'hi there';
$phar = $phar->convertToExecutable(Phar::PHAR, Phar::BZ2);
var_dump($phar->isFileFormat(Phar::PHAR));
var_dump($phar->isCompressed());
var_dump(strlen($phar->getStub()));
copy($fname . '.bz2', $fname2);
$phar = new Phar($fname2);
var_dump($phar->isFileFormat(Phar::PHAR));
var_dump($phar->isCompressed() == Phar::BZ2);
var_dump(strlen($phar->getStub()));
?>
===DONE===