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


PHP Phar::convertToData方法代码示例

本文整理汇总了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;
 }
开发者ID:peopleplan,项目名称:Pyrus,代码行数:38,代码来源:Phar.php

示例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";
}
开发者ID:noose,项目名称:zf2,代码行数:31,代码来源:_buildPhars.php

示例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');
开发者ID:alphaxxl,项目名称:hhvm,代码行数:31,代码来源:phar_decompress.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);
开发者ID:zaky-92,项目名称:php-1,代码行数:31,代码来源:ext_phar_tests_pharfileinfo_setmetadata.php

示例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);
开发者ID:gleamingthecube,项目名称:php,代码行数:31,代码来源:ext_phar_tests_phar_convert_again.php

示例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";
开发者ID:zaky-92,项目名称:php-1,代码行数:31,代码来源:ext_phar_tests_badparameters.php

示例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');
开发者ID:alphaxxl,项目名称:hhvm,代码行数:17,代码来源:bug48377.php


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