本文整理汇总了PHP中Phar::getMetaData方法的典型用法代码示例。如果您正苦于以下问题:PHP Phar::getMetaData方法的具体用法?PHP Phar::getMetaData怎么用?PHP Phar::getMetaData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Phar
的用法示例。
在下文中一共展示了Phar::getMetaData方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: realpath
/**
* @param string $package path to package file
*/
function __construct($package, \Pyrus\Package $parent)
{
$package = realpath($package);
if (!$package) {
throw new Phar\Exception('Phar package ' . $package . ' does not exist');
}
$pxml = false;
$this->archive = $package;
try {
if (\Phar::isValidPharFilename($package, 1)) {
$phar = new \Phar($package, \RecursiveDirectoryIterator::KEY_AS_FILENAME);
$pxml = 'phar://' . $package . '/' . $phar->getMetaData();
} else {
$phar = new \PharData($package, \RecursiveDirectoryIterator::KEY_AS_FILENAME);
if ($phar->getMetaData()) {
$pxml = 'phar://' . $package . '/' . $phar->getMetaData();
}
}
} catch (\Exception $e) {
throw new Phar\Exception('Could not open Phar archive ' . $package, $e);
}
$package = str_replace('\\', '/', $package);
try {
if ($pxml === false) {
$info = pathinfo($package);
$internal = $info['filename'];
if (isset($phar[$internal . '/.xmlregistry'])) {
if ($phar instanceof \PharData) {
$iterate = new \PharData('phar://' . $package . '/' . $internal . '/.xmlregistry');
} else {
$iterate = new \Phar('phar://' . $package . '/' . $internal . '/.xmlregistry');
}
foreach (new \RecursiveIteratorIterator($iterate, \RecursiveIteratorIterator::LEAVES_ONLY) as $file) {
$filename = $file->getFileName();
// default to new package.xml
if (preg_match('@^(.+)\\-package.xml$@', $filename)) {
$pxml = $file->getPathName();
break;
}
}
} else {
foreach (array('package2.xml', $internal . '/' . 'package2.xml', 'package.xml', $internal . '/' . 'package.xml') as $checkfile) {
if (isset($phar[$checkfile])) {
$this->_BCpackage = true;
$pxml = $phar[$checkfile]->getPathName();
break;
}
}
}
}
if ($pxml === false) {
throw new Phar\Exception('No package.xml in archive');
}
} catch (\Exception $e) {
throw new Phar\Exception('Could not extract Phar archive ' . $package, $e);
}
parent::__construct(new \Pyrus\PackageFile($pxml, 'Pyrus\\PackageFile\\v2'), $parent);
}
示例2: empty
Phar::mapPhar('neo4jphp.phar');
spl_autoload_register(function ($className) {
if (strpos($className, 'Everyman\\Neo4j\\') !== 0) {
return;
}
$libPath = 'phar://neo4jphp.phar/lib/';
$classFile = str_replace('\\', DIRECTORY_SEPARATOR, $className) . '.php';
$classPath = $libPath . $classFile;
if (file_exists($classPath)) {
require $classPath;
}
});
if ('cli' === php_sapi_name() && basename(__FILE__) === basename($_SERVER['argv'][0])) {
$command = empty($_SERVER['argv'][1]) ? '-help' : $_SERVER['argv'][1];
$me = new Phar('neo4jphp.phar');
$meta = $me->getMetaData();
if ($command == '-help') {
echo <<<HELP
Neo4jPHP version {$meta['version']}
{$_SERVER['argv'][0]} [-help|-license|-readme|-version|<host>] <port>
-help Display help text
-license Display software license
-readme Display README
-version Display version information
<host> (<port>) Test connection to Neo4j instance on host (port defaults to 7474)
HELP;
} else {
if ($command == '-license') {
echo file_get_contents('phar://neo4jphp.phar/LICENSE') . "\n\n";
示例3: dirname
$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
$pname = 'phar://' . $fname;
$file = "<?php __HALT_COMPILER(); ?>";
$files = array();
$pmeta = 'hi there';
$files['a'] = array('cont' => 'a');
$files['b'] = array('cont' => 'b');
$files['c'] = array('cont' => 'c', 'meta' => array('hi', 'there'));
$files['d'] = array('cont' => 'd', 'meta' => array('hi' => 'there', 'foo' => 'bar'));
include 'files/phar_test.inc';
foreach ($files as $name => $cont) {
var_dump(file_get_contents($pname . '/' . $name));
}
$phar = new Phar($fname);
var_dump($phar->hasMetaData());
var_dump($phar->getMetaData());
var_dump($phar->delMetaData());
var_dump($phar->getMetaData());
var_dump($phar->delMetaData());
var_dump($phar->getMetaData());
foreach ($files as $name => $cont) {
echo " meta {$name}\n";
var_dump($phar[$name]->hasMetadata());
var_dump($phar[$name]->getMetadata());
var_dump($phar[$name]->delMetadata());
var_dump($phar[$name]->getMetadata());
}
unset($phar);
foreach ($files as $name => $cont) {
var_dump(file_get_contents($pname . '/' . $name));
}