本文整理汇总了PHP中Phar::getSupportedSignatures方法的典型用法代码示例。如果您正苦于以下问题:PHP Phar::getSupportedSignatures方法的具体用法?PHP Phar::getSupportedSignatures怎么用?PHP Phar::getSupportedSignatures使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Phar
的用法示例。
在下文中一共展示了Phar::getSupportedSignatures方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: compile
/**
* Compiles skylab into a single phar file
*
* @param string $version
* @param string $pharFile The full path to the file to create
* @throws \RuntimeException
*/
public function compile($version, $pharFile = 'skylab.phar')
{
if (file_exists($pharFile)) {
unlink($pharFile);
}
$this->version = $version;
$date = new \DateTime();
$date->setTimezone(new \DateTimeZone('UTC'));
$this->versionDate = $date->format('Y-m-d H:i:s');
$phar = new \Phar($pharFile, 0, 'skylab.phar');
$sign = \Phar::getSupportedSignatures();
if (in_array(\Phar::SHA512, $sign)) {
$phar->setSignatureAlgorithm(\Phar::SHA512);
} elseif (in_array(\Phar::SHA256, $sign)) {
$phar->setSignatureAlgorithm(\Phar::SHA256);
} elseif (in_array(\Phar::SHA1, $sign)) {
$phar->setSignatureAlgorithm(\Phar::SHA1);
} elseif (in_array(\Phar::MD5, $sign)) {
$phar->setSignatureAlgorithm(\Phar::MD5);
}
$phar->startBuffering();
$finder = new Finder();
$finder->files()->ignoreVCS(true)->name('*.php')->name('*.yml')->notName('Compiler.php')->in(__DIR__ . '/../..');
foreach ($finder as $file) {
$this->addFile($phar, $file);
}
$finder = new Finder();
$finder->files()->ignoreVCS(true)->name('*.php')->name('*.pem')->exclude('Tests')->in(__DIR__ . '/../../../vendor/');
foreach ($finder as $file) {
$this->addFile($phar, $file);
}
$finder = new Finder();
$finder->files()->ignoreVCS(true)->name('*.yml')->in(__DIR__ . '/../../../config/');
foreach ($finder as $file) {
$this->addFile($phar, $file);
}
$finder = new Finder();
$finder->files()->ignoreVCS(true)->name('*.twig')->in(__DIR__ . '/../../../templates/');
foreach ($finder as $file) {
$this->addFile($phar, $file);
}
$this->addSkylabBin($phar);
$phar->setStub($this->getStub());
$phar->stopBuffering();
$this->addFile($phar, new \SplFileInfo(__DIR__ . '/../../../LICENSE'), false);
unset($phar);
}
示例2: __construct
/**
* Constructor for the class.
* @param string $fetch_dir temporary directory for the files
* @param string $verified_dir directory for verified archives
* @param string $pub_key_file path of a PEM file with public key
* @throws RuntimeException
*/
public function __construct($fetch_dir, $verified_dir, $pub_key_file = null)
{
if (!class_exists('Phar')) {
throw new RuntimeException("Phar is not enabled in this PHP configuration!");
}
$this->fetch_dir = $fetch_dir;
if (!is_dir($this->fetch_dir)) {
throw new RuntimeException("Temporary directory {$fetch_dir} does not exist!");
}
$this->verified_dir = $verified_dir;
if (!is_dir($this->verified_dir)) {
throw new RuntimeException("Verified directory {$verified_dir} does not exist!");
}
$this->pub_key_file = $pub_key_file;
if (!is_null($this->pub_key_file) && !in_array('OpenSSL', Phar::getSupportedSignatures())) {
throw new RuntimeException("No support for OpenSSL signatures in this PHP configuration!");
}
}
示例3: selectSignatureType
private function selectSignatureType(\Phar $phar)
{
if ($this->signatureType !== NULL) {
return $this->supportedSignatureTypes[$this->signatureType];
}
$supported = $phar->getSupportedSignatures();
foreach ($this->supportedSignatureTypes as $candidate => $type) {
if (in_array($candidate, $supported)) {
return $type;
}
}
// Is there any PHP Version out there that does not support at least SHA-1?
// But hey, fallback to md5, better than nothing
return \Phar::MD5;
}
示例4: Phar
<?php
$phar = new Phar('dbsync.phar');
$phar->buildFromDirectory('phar');
$phar->setDefaultStub('index.php');
$signatures = Phar::getSupportedSignatures();
$phar->setSignatureAlgorithm(PHAR::SHA512);
$phar->extractTo('pharTest');
示例5: var_dump
<?php
var_dump(Phar::getSupportedSignatures());
?>
===DONE===
示例6: ajaxForm
function ajaxForm($dt = '')
{
$return = true;
//se for informado apenas o nome da nova seção - vindo do ajax
if (!is_array($dt)) {
$return = false;
$v = $dt;
$dt = array();
$dt[$v] = array('o' => RPATH, 'd' => dirname(RPATH) . DS . $v . '.phar', 'i' => RPATH . 'index.php', 'k' => dirname(RPATH) . DS . $v . '.phar.pubkey', 'r' => 'checked', 'z' => 'checked');
}
$kt = $o = '';
//pegando as assinaturas válidas
foreach (\Phar::getSupportedSignatures() as $k) {
$kt .= '<option value="' . $k . '">' . $k . '</option>';
}
foreach ($dt as $k => $v) {
$o .= '<div class="listagem">
<h3>Conversor PHAR <input name="del" class="bt_del" type="button" value="" title="Excluir este recurso." /></h3>
<div>
<label>Origem</label>
<input name="' . $k . '[o]" type="text" value="' . $v['o'] . '">
<label>Destino</label>
<input name="' . $k . '[d]" type="text" value="' . $v['d'] . '">
<label>Chave de Segurança : </label>
<select name="' . $k . '[t]">' . $kt . '</select>
<input name="' . $k . '[k]" type="text" value="' . $v['k'] . '">
<label>Stub [executar como default]</label>
<input name="' . $k . '[i]" type="text" value="' . $v['i'] . '">
<label><input name="' . $k . '[z]" type="checkbox" value="checked" ' . @$v['z'] . ' title="On/Off - Compacta o arquivo PHAR no final da conversão."> Compactar</label>
</div>
</div>';
}
if ($return) {
return $o;
} else {
echo $o;
}
}
示例7: selectSignatureType
private function selectSignatureType(\Phar $phar)
{
$map = array('SHA-512' => \Phar::SHA512, 'SHA-256' => \Phar::SHA256, 'SHA-1' => \Phar::SHA1);
$supported = $phar->getSupportedSignatures();
foreach ($map as $candidate => $type) {
if (in_array($candidate, $supported)) {
return $type;
}
}
// Is there any PHP Version out there that does not support at least SHA-1?
// But hey, fallback to md5, better than nothing
return \Phar::MD5;
}