本文整理汇总了PHP中Phar::delete方法的典型用法代码示例。如果您正苦于以下问题:PHP Phar::delete方法的具体用法?PHP Phar::delete怎么用?PHP Phar::delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Phar
的用法示例。
在下文中一共展示了Phar::delete方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Phar
<?php
// 创建phar包的辅助脚本
// 使用方式:
// 将本脚本放置到要打包的目录下,修改对应的名字运行即可
$file = 'Sample.phar';
// 包的名称,在stub中也作为入口前缀
$exts = ['php', 'html', 'inc'];
// 需要打包的文件后缀
$dir = __DIR__;
// 需要打包的目录
$phar = new Phar(__DIR__ . '/' . $file, FilesystemIterator::CURRENT_AS_FILEINFO | FilesystemIterator::KEY_AS_FILENAME, $file);
// 开始打包
$phar->startBuffering();
// 将后缀名相关的文件打包
foreach ($exts as $ext) {
$phar->buildFromDirectory($dir, '/\\.' . $ext . '$/');
}
// 把build.php本身摘除
$phar->delete('build.php');
// 设置入口
$phar->setStub("<?php\nPhar::mapPhar('{$file}');\nrequire 'phar://{$file}/portal/index.php';\n__HALT_COMPILER();\n?>");
$phar->stopBuffering();
// 打包完成
echo "Finished {$file}\n";
示例2: file_get_contents
<?php
$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
$pname = 'phar://' . $fname;
$file = "<?php\nPhar::mapPhar('hio');\n__HALT_COMPILER(); ?>";
$files = array();
$files['a'] = 'a';
include 'files/phar_test.inc';
include $fname;
$phar = new Phar($fname);
echo file_get_contents($pname . '/a') . "\n";
$phar->delete('a');
echo file_get_contents($pname . '/a') . "\n";
示例3: Phar
<?php
require_once './oktopus/Oktopus/Engine.php';
Oktopus\Engine::start('/tmp/');
Oktopus\Engine::autoloader()->addPath('./Engine', true, true);
$app = $_GET['app'];
ini_set('phar.readonly', 0);
$phar = new Phar('./' . $app . '.phar', 0, $app . '.phar');
$phar->buildFromDirectory('./');
var_dump(Server::getInstance()->getConfig("urlApplications"));
$dir = new DirectoryIterator(Server::getInstance()->getConfig("urlApplications"));
foreach ($dir as $file) {
if ($file->getBaseName() != $app) {
$phar->delete('./applications/');
}
}
示例4: PharData
}
$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";
}
try {
$b->delete('oops');
} catch (Exception $e) {
echo $e->getMessage() . "\n";
}
echo $a->getPath() . "\n";
try {
$a->setAlias('oops');
} catch (Exception $e) {
echo $e->getMessage() . "\n";
}
try {
示例5: substr
}
if (is_file($path . $read)) {
$result[$path . $read] = substr($path . $read, strlen($root));
} else {
if (is_dir($path . $read)) {
$result = array_merge($result, scan($path . $read, $root));
}
}
}
closedir($open);
return $result;
}
@unlink('build/imager.phar');
$paths = array('bower_components/Aura.Autoload/src', 'bower_components/console', 'src');
$phar = new Phar('build/imager.phar');
foreach ($paths as $path) {
foreach (scan($path) as $absolute => $relative) {
$phar->addFromString($path . '/' . $relative, php_strip_whitespace($absolute));
}
}
$phar->delete('bower_components/console/.bower.json');
$phar->delete('bower_components/console/.gitignore');
$phar->delete('bower_components/console/CHANGELOG.md');
$phar->delete('bower_components/console/composer.json');
$phar->delete('bower_components/console/LICENSE');
$phar->delete('bower_components/console/README.md');
$phar->delete('bower_components/console/phpunit.xml.dist');
$phar->addFromString('bower_components/Aura.Autoload/autoload.php', php_strip_whitespace('bower_components/Aura.Autoload/autoload.php'));
$phar->addFromString('index.php', '<' . '?php' . PHP_EOL . 'require_once(dirname(__FILE__) . \'/src/cli.php\');');
$phar->compressFiles(Phar::GZ);
echo 'Done.';
示例6: Phar
$_SERVER['argv'][2] .= '/';
}
// Initialize the stub parser
$stubs = new Stub_Parser();
$stubs->register('base', './stubs/base.php');
$stubs->register('addon', './stubs/addon.php');
$stubs->register('standalone', './stubs/standalone.php');
// Build the archive
$phar = new Phar($_SERVER['argv'][3]);
$phar->startBuffering();
$phar->buildFromIterator(new KeyFilter(new RecursiveIteratorIterator(new RecursiveDirectoryIterator($_SERVER['argv'][2])), '.svn'), $_SERVER['argv'][2]);
// Add the stub
if ($_SERVER['argv'][1] == 'Opl') {
// Define a stub for the core
$phar->setStub(file_get_contents($_SERVER['argv'][2] . 'Base.php') . $stubs->create('base'));
$phar->delete('Base.php');
} else {
// Define a stub for other libraries
$stubs->library = $_SERVER['argv'][1];
if (isset($phar['Class.php'])) {
$phar->setStub(file_get_contents($_SERVER['argv'][2] . 'Class.php') . $stubs->create('addon'));
$phar->delete('Class.php');
} else {
$phar->setStub($stubs->create('standalone'));
}
}
$phar->stopBuffering();
echo $_SERVER['argv'][3] . " created\r\n";
} catch (Exception $e) {
die('Some error occured: ' . $e->getMessage() . "\n");
}
示例7: Phar
<?php
$dir = __DIR__;
// 需要打包的目录
$file = 'BaiduBce.phar';
// 包的名称, 注意它不仅仅是一个文件名, 在stub中也会作为入口前缀
$phar = new Phar(__DIR__ . '/' . $file, FilesystemIterator::CURRENT_AS_FILEINFO | FilesystemIterator::KEY_AS_FILENAME, $file);
// 开始打包
$phar->startBuffering();
$phar->buildFromDirectory($dir);
// 把build.php本身摘除
$phar->delete('PharBuilder.php');
// 设置默认入口
$phar->setStub("<?php\nPhar::mapPhar('{$file}');\nrequire 'phar://{$file}/index.php';\n__HALT_COMPILER();\n?>");
$phar->stopBuffering();
// 打包完成
echo "Finished {$file}\n";
示例8: Phar
<?php
$p = new Phar(__FILE__);
var_dump(file_exists("phar://" . __FILE__ . "/test.txt"));
$p->delete("test.txt");
clearstatcache();
var_dump(file_exists("phar://" . __FILE__ . "/test.txt"));
echo "ok\n";
__halt_compiler(); ?>
6test.txtшїтHzzoн¶hi
сgµ$Пh±§вуUxBвІGBMB
示例9: Phar
<?php
// 需要打包的文件后缀
$exts = ['php'];
// 包的名称, 注意它不仅仅是一个文件名, 在stub中也会作为入口前缀
$file = 'heresy.phar';
$phar = new Phar(__DIR__ . '/' . $file, FilesystemIterator::CURRENT_AS_FILEINFO | FilesystemIterator::KEY_AS_FILENAME, $file);
// 开始
$phar->startBuffering();
// 将后缀名相关的文件打包
foreach ($exts as $ext) {
$phar->buildFromDirectory(__DIR__, '/\\.' . $ext . '$/');
}
// 去除当前打包文件
$phar->delete(pathinfo(__FILE__, PATHINFO_BASENAME));
// 压缩
$phar->compressFiles(Phar::GZ);
// Phar::NONE
// 设置入口
/*
$phar->setStub("<?php Phar::mapPhar('{$file}'); require 'phar://{$file}/bootstrap.php'; __HALT_COMPILER(); ?>");
*/
$phar->setStub($phar->createDefaultStub('bootstrap/heresy.php'));
// 完成
$phar->stopBuffering();
echo "{$file}\n";