本文整理汇总了PHP中Phar::getAlias方法的典型用法代码示例。如果您正苦于以下问题:PHP Phar::getAlias方法的具体用法?PHP Phar::getAlias怎么用?PHP Phar::getAlias使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Phar
的用法示例。
在下文中一共展示了Phar::getAlias方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testWriting
/**
* Test that the Writing is successful.
*
* @return void
*
* @dataProvider testWritingFlagsProvider
*/
public function testWriting($compression, $signatureName, $signatureFlag)
{
$pharfile = $this->getTempFile('temp.phar');
$phar = new Pharchive();
$phar->setStub($stubData = <<<EOF
#!/usr/bin/php
<?php
/*STUB!*/
__HALT_COMPILER();
EOF
)->setSignatureFlags($signatureFlag);
$file = new FileEntry();
$file->setFilename('/bin/script')->setContent($fileData = <<<EOF
#!/usr/bin/php
<?php
echo 'hello world';
EOF
);
if ($compression) {
$file->setCompression($compression);
}
$phar->addFile($file);
$writer = new PharWriter();
$writer->save($phar, $pharfile);
unset($writer);
$phar = new \Phar($pharfile);
// As we did not set an alias, php defaults to the file name.
$this->assertEquals($pharfile, $phar->getAlias());
$signature = $phar->getSignature();
$this->assertEquals($signatureName, strtolower(str_replace('-', '', $signature['hash_type'])));
/** @var \PharFileInfo[] $files */
$files = array_values(iterator_to_array($phar->getChildren()));
$this->assertEquals('phar://' . $pharfile . '/bin/script', $files[0]->getPathname());
$this->assertEquals($fileData, $files[0]->getContent());
}
示例2: dirname
$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));
var_dump($phar->isFileFormat(Phar::ZIP));
var_dump($phar->getStub());
var_dump($phar->getAlias());
echo "================= convertToPhar() ====================\n";
示例3: dirname
<?php
$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
$pname = 'phar://' . $fname;
$file = '<?php echo "first stub\\n"; __HALT_COMPILER(); ?>';
$files = array();
$files['a'] = 'a';
$files['b'] = 'b';
$files['c'] = 'c';
include 'files/phar_test.inc';
$phar = new Phar($fname);
echo $phar->getAlias() . "\n";
$phar->setAlias('test');
echo $phar->getAlias() . "\n";
?>
===DONE===
<?php
error_reporting(0);
unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php');
unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phartmp.php');
__halt_compiler();
?>
示例4: dirname
<?php
$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.tar';
$fname2 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '2.phar.tar';
$phar = new Phar($fname);
$phar->setStub('<?php echo "first stub\\n"; __HALT_COMPILER(); ?>');
$phar->setAlias('hio');
$files = array();
$files['a'] = 'a';
$files['b'] = 'b';
$files['c'] = 'c';
foreach ($files as $n => $file) {
$phar[$n] = $file;
}
$phar->stopBuffering();
echo $phar->getAlias() . "\n";
$phar->setAlias('test');
echo $phar->getAlias() . "\n";
copy($fname, $fname2);
$phar->setAlias('unused');
$a = new Phar($fname2);
echo $a->getAlias() . "\n";
?>
===DONE===
<?php
error_reporting(0);
unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.tar');
unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phartmp.tar');
__halt_compiler();
?>
示例5: dirname
$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.zip';
$fname2 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '2.phar.zip';
$fname3 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '3.phar.zip';
$phar = new Phar($fname);
$phar->setStub('<?php echo "first stub\\n"; __HALT_COMPILER(); ?>');
$phar->setAlias('hio');
$files = array();
$files['a'] = 'a';
$files['b'] = 'b';
$files['c'] = 'c';
foreach ($files as $n => $file) {
$phar[$n] = $file;
}
$phar->stopBuffering();
echo $phar->getAlias() . "\n";
$phar->setAlias('test');
echo $phar->getAlias() . "\n";
// test compression
$phar->compressFiles(Phar::GZ);
copy($fname, $fname2);
$phar->setAlias('unused');
$p2 = new Phar($fname2);
echo $p2->getAlias(), "\n";
$p2->compressFiles(Phar::BZ2);
copy($fname2, $fname3);
$p2->setAlias('unused2');
$p3 = new Phar($fname3);
echo $p3->getAlias(), "\n";
?>
===DONE===
示例6: PharData
<?php
try {
$a = new PharData(dirname(__FILE__) . '/files/bzip2.zip');
foreach ($a as $entry => $file) {
echo $file->getContent();
}
$a = new Phar(dirname(__FILE__) . '/files/bz2_alias.phar.zip');
var_dump($a->getAlias());
} catch (Exception $e) {
echo $e->getMessage() . "\n";
}
?>
===DONE===
示例7: Phar
<?php
$p = new Phar(__FILE__);
var_dump($p->getAlias());
$p2 = new Phar(__FILE__);
$p->setAlias("hi");
echo $p2->getAlias(), "\n";
echo "ok\n";
__halt_compiler(); ?>
6test.txtt��Hzzo�hi
�����Ji5���4
QCڱ�GBMB