本文整理汇总了PHP中Phar::convertToData方法的典型用法代码示例。如果您正苦于以下问题:PHP Phar::convertToData方法的具体用法?PHP Phar::convertToData怎么用?PHP Phar::convertToData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Phar
的用法示例。
在下文中一共展示了Phar::convertToData方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: init
/**
* Initialize the package creator
*/
function init()
{
try {
if (file_exists($this->path)) {
@unlink($this->path);
}
$ext = strstr(strrchr($this->path, '-'), '.');
if (!$ext) {
$ext = strstr(strrchr($this->path, '/'), '.');
if (!$ext) {
$ext = strstr(strrchr($this->path, '\\'), '.');
}
}
if (!$ext) {
$ext = strstr($this->path, '.');
}
$a = $this->_classname;
$this->phar = new $a($this->path);
if ($this->phar instanceof Phar) {
$this->phar = $this->phar->convertToExecutable($this->format, $this->compression, $ext);
} else {
$this->phar = $this->phar->convertToData($this->format, $this->compression, $ext);
}
$this->phar->startBuffering();
if ($this->phar instanceof Phar) {
$this->phar->setStub($this->stub);
}
if ($this->format == Phar::ZIP) {
$this->compression = $comp;
}
} catch (Exception $e) {
throw new \Pyrus\Developer\Creator\Exception('Cannot open Phar archive ' . $this->path, $e);
}
$this->_started = false;
}
示例2: buildModulePhar
function buildModulePhar($name, $format = Phar::PHAR, $compression = Phar::NONE, $executable = true, $fake = false)
{
echo "Building {$name}...\t";
$glob = glob($name.'.*');
if (count($glob) > 0) {
foreach ($glob as $file) {
if (!is_dir($file)) {
unlink($file);
}
}
}
$filename = $name . '.phar';
$phar = new Phar($filename);
if ($fake) {
$phar['Module.php'] = '<?php //no class here';
} else {
$phar['Module.php'] = "<?php \n\nnamespace $name;\n\nclass Module\n{}";
}
if (false === $executable) {
$phar->convertToData($format, $compression);
} else {
$phar->setDefaultStub('Module.php', 'Module.php');
if ($format !== Phar::PHAR || $compression !== Phar::NONE) {
$phar->convertToExecutable($format, $compression);
}
}
if ($format !== Phar::PHAR || $compression !== Phar::NONE) {
unlink($filename);
}
echo "Done!\n";
}
示例3: Phar
$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 {
$zip->decompress();
} catch (Exception $e) {
echo $e->getMessage() . "\n";
}
?>
===DONE===
<?php
unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php');
示例4: dirname
<?php
$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar';
$pname = 'phar://' . $fname;
$phar = new Phar($fname);
$phar['a/b'] = 'hi there';
$tar = $phar->convertToData(Phar::TAR);
$b = $phar['a/b'];
try {
$phar['a']->setMetadata('hi');
} catch (Exception $e) {
echo $e->getMessage(), "\n";
}
try {
$phar['a']->delMetadata();
} catch (Exception $e) {
echo $e->getMessage(), "\n";
}
ini_set('phar.readonly', 1);
try {
$b->setMetadata('hi');
} catch (Exception $e) {
echo $e->getMessage(), "\n";
}
try {
$b->delMetadata();
} catch (Exception $e) {
echo $e->getMessage(), "\n";
}
ini_set('phar.readonly', 0);
$b->setMetadata(1, 2, 3);
示例5: dirname
<?php
$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar';
$fname2 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '2.tbz';
$pname = 'phar://' . $fname;
$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);
$zip = $phar->convertToData(Phar::ZIP);
echo $zip->getPath() . "\n";
$tgz = $phar->convertToData(Phar::TAR, Phar::GZ);
echo $tgz->getPath() . "\n";
$tbz = $phar->convertToData(Phar::TAR, Phar::BZ2);
echo $tbz->getPath() . "\n";
try {
$phar = $tbz->convertToExecutable(Phar::PHAR, Phar::NONE);
} catch (Exception $e) {
echo $e->getMessage() . "\n";
}
copy($tbz->getPath(), $fname2);
$tbz = new PharData($fname2);
$phar = $tbz->convertToExecutable(Phar::PHAR, Phar::NONE);
echo $phar->getPath() . "\n";
$phar['a'] = 'hi';
$phar['a']->setMetadata('hi');
$zip = $phar->convertToExecutable(Phar::ZIP);
示例6: Phar
Phar::mungServer('hi');
Phar::createDefaultStub(array());
Phar::loadPhar(array());
Phar::canCompress('hi');
try {
$a = new Phar(array());
} catch (TypeError $e) {
print_exception($e);
}
try {
$a = new Phar(dirname(__FILE__) . '/files/frontcontroller10.phar');
} catch (PharException $e) {
print_exception($e);
}
$a->convertToExecutable(array());
$a->convertToData(array());
try {
$b = new PharData(dirname(__FILE__) . '/whatever.tar');
} catch (PharException $e) {
print_exception($e);
}
try {
$c = new PharData(dirname(__FILE__) . '/whatever.zip');
} catch (PharException $e) {
print_exception($e);
}
$b->delete(array());
try {
$a->delete('oops');
} catch (Exception $e) {
echo $e->getMessage() . "\n";
示例7: dirname
<?php
$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar';
$fname2 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.zip';
touch($fname2);
$phar = new Phar($fname, 0, 'a.phar');
$phar['x'] = 'hi';
try {
$phar->convertToData(Phar::ZIP, Phar::NONE, 'zip');
} catch (BadMethodCallException $e) {
echo $e->getMessage(), "\n";
}
?>
===DONE===
<?php
unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar');
unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.zip');