本文整理匯總了PHP中Phar::commit方法的典型用法代碼示例。如果您正苦於以下問題:PHP Phar::commit方法的具體用法?PHP Phar::commit怎麽用?PHP Phar::commit使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Phar
的用法示例。
在下文中一共展示了Phar::commit方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: exit
* Usage: php phar_create_from_dir.php \<archive\> \<directory\> [\<regex\>]
*
* Create phar archive \<archive\> using entries from \<directory\> that
* optionally match \<regex\>.
*/
if ($argc < 3) {
echo <<<EOF
php phar_from_dir.php archive directory [regex]
Packs files in a given directory into a phar archive.
archive name of the archive to create
directory input directory to pack
regex optional expression to match files in directory
EOF;
exit(1);
}
$phar = new Phar($argv[1], 0, 'newphar');
$dir = new RecursiveDirectoryIterator($argv[2]);
$dir = new RecursiveIteratorIterator($dir);
if ($argc > 3) {
$dir = new RegexIterator($dir, '/' . $argv[3] . '/');
}
$phar->begin();
foreach ($dir as $file) {
echo "{$file}\n";
copy($file, "phar://newphar/{$file}");
}
$phar->commit();