本文整理汇总了PHP中Phar::count方法的典型用法代码示例。如果您正苦于以下问题:PHP Phar::count方法的具体用法?PHP Phar::count怎么用?PHP Phar::count使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Phar
的用法示例。
在下文中一共展示了Phar::count方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: verify_pheanstalk_phar
function verify_pheanstalk_phar()
{
$phar = new Phar(PHAR_FULLPATH);
printf("- %s built with %d files.\n", PHAR_FILENAME, $phar->count());
}
示例2: phar_to
//.........这里部分代码省略.........
* @WARNING This routine can become resource intensive on large directories.
* Mostly because of the compression routines applied here intuitively. It takes some time.
* See: {@link env::maximize_time_memory_limits()}
*/
public function phar_to($dir, $to, $stub_file, $strip_ws = TRUE, $compress = TRUE, $compressable_extensions = array('php', 'phps'), $is_phar_var_suffix = 'stub')
{
$this->check_arg_types('string:!empty', 'string:!empty', 'string:!empty', 'boolean', 'boolean', 'array:!empty', 'string:!empty', func_get_args());
$dir = $this->n_seps($dir);
$to = $this->n_seps($to);
$to_dir = $this->n_seps_up($to);
if (!is_dir($dir)) {
throw $this->©exception($this->method(__FUNCTION__) . '#source_dir_missing', get_defined_vars(), $this->__('Unable to PHAR a directory (source `dir` missing).') . sprintf($this->__('Non-existent source directory: `%1$s`.'), $dir));
}
if (!is_readable($dir)) {
throw $this->©exception($this->method(__FUNCTION__) . '#read_write_issues', get_defined_vars(), $this->__('Unable to PHAR a directory; not readable, due to permission issues.') . ' ' . sprintf($this->__('Need this directory to be readable please: `%1$s`.'), $dir));
}
if (file_exists($to)) {
throw $this->©exception($this->method(__FUNCTION__) . '#existing_phar', get_defined_vars(), $this->__('Unable to PHAR a directory; destination PHAR file already exists.') . ' ' . sprintf($this->__('Please delete this file first: `%1$s`.'), $to));
}
if ($this->extension($to) !== 'phar') {
throw $this->©exception($this->method(__FUNCTION__) . '#invalid_phar_file', get_defined_vars(), $this->__('Unable to PHAR a directory; invalid destination PHAR file.') . ' ' . sprintf($this->__('Please use a `.phar` extension instead of: `%1$s`.'), $to));
}
if (!is_dir($to_dir)) {
throw $this->©exception($this->method(__FUNCTION__) . '#phar_to_dir_missing', get_defined_vars(), $this->__('Destination PHAR directory does NOT exist yet.') . ' ' . sprintf($this->__('Please check this directory: `%1$s`.'), $to_dir));
}
if (!is_writable($to_dir)) {
throw $this->©exception($this->method(__FUNCTION__) . '#read_write_issues', get_defined_vars(), $this->__('Unable to PHAR a directory; destination not writable due to permission issues.') . ' ' . sprintf($this->__('Need this directory to be writable please: `%1$s`.'), $to_dir));
}
if (!\Phar::canWrite()) {
throw $this->©exception($this->method(__FUNCTION__) . '#read_write_issues', get_defined_vars(), $this->__('Unable to PHAR a directory; PHP configuration does NOT allow write access.') . ' ' . $this->__('Need this INI setting please: `phar.readonly = 0`.'));
}
if (!is_file($stub_file)) {
throw $this->©exception($this->method(__FUNCTION__) . '#missing_stub_file', get_defined_vars(), $this->__('Unable to PHAR a directory; missing stub file.') . ' ' . sprintf($this->__('File does NOT exist: `%1$s`.'), $stub_file));
}
if (!is_readable($stub_file)) {
throw $this->©exception($this->method(__FUNCTION__) . '#stub_file_issues', get_defined_vars(), $this->__('Unable to PHAR a directory; permission issues with stub file.') . ' ' . sprintf($this->__('Need this file to be writable please: `%1$s`.'), $stub_file));
}
// Phar class throws exceptions on failure.
$_stub_file_is_phar_var = '$GLOBALS[\'is_phar_' . $this->©string->esc_sq($is_phar_var_suffix) . '\'] = \'phar://\'.__FILE__;';
$_stub_file_contents = $strip_ws ? $this->©php->strip_whitespace($stub_file) : file_get_contents($stub_file);
$_stub_file_contents = trim(preg_replace('/\\W\\?\\>\\s*$/', '', $_stub_file_contents, 1));
// No close tag & trim.
$_stub_file_contents = preg_replace('/\\<\\?php|\\<\\?/i', '<?php ' . $_stub_file_is_phar_var, $_stub_file_contents, 1);
$_stub_file_contents = preg_replace('/\\W__HALT_COMPILER\\s*\\(\\s*\\)\\s*;/i', '', $_stub_file_contents, 1) . ' __HALT_COMPILER();';
$_phar = new \Phar($to, $this->iteration_flags());
$_phar->startBuffering();
// Don't create file yet (wait until we're done here).
$_phar->setStub($_stub_file_contents);
// Defines the stub for this PHAR file.
if (!$strip_ws && !$compress) {
$_phar->buildFromDirectory($dir);
} else {
$_strippable_extensions = array('php');
$_regex_compressable_extensions = $this->©string->preg_quote_deep($compressable_extensions, '/');
$_regex_compressable_extensions = '/\\.(?:' . implode('|', $_regex_compressable_extensions) . ')$/i';
$_temp_dir = $this->temp() . '/' . $this->©string->unique_id() . '-' . basename($dir);
$this->copy_to($dir, $_temp_dir);
$_temp_dir_iteration = $this->iteration($_temp_dir);
if ($strip_ws) {
foreach ($_temp_dir_iteration as $_dir_file) {
if (!$_dir_file->isFile()) {
continue;
}
$_path = $_dir_file->getPathname();
$_phar_path = $_dir_file->getSubPathName();
$_extension = $this->©file->extension($_path);
if (in_array($_extension, $_strippable_extensions, TRUE)) {
file_put_contents($_path, $this->©php->strip_whitespace($_path, TRUE));
}
}
}
$_phar->buildFromDirectory($_temp_dir, $_regex_compressable_extensions);
if ($compress && $_phar->count()) {
// Compressing files?
$_phar->compressFiles(\Phar::GZ);
}
foreach ($_temp_dir_iteration as $_dir_file) {
if (!$_dir_file->isFile()) {
continue;
}
$_path = $_dir_file->getPathname();
$_phar_path = $_dir_file->getSubPathName();
$_extension = $this->©file->extension($_path);
if (!in_array($_extension, $compressable_extensions, TRUE)) {
$_phar->addFile($_path, $_phar_path);
}
}
}
$_phar->stopBuffering();
// Write to disk now.
unset($_phar, $_stub_file_is_phar_var, $_stub_file_contents, $_strippable_extensions, $_regex_compressable_extensions);
unset($_temp_dir_iteration, $_dir_file, $_path, $_phar_path, $_extension);
if (isset($_temp_dir)) {
// A little more housekeeping now.
$this->delete($_temp_dir);
}
unset($_temp_dir);
return $to;
// It's a good day in Eureka!
}
示例3: info
info("Add File: {$file}");
$p->addFile($file, basename($file));
}
}
if ($index && $webindex) {
info("Index: {$index}");
info("Web Index: {$webindex}");
$p->setDefaultStub($index, $webindex);
} else {
if ($index) {
info("Index: {$index}");
$p->setDefaultStub($index);
} else {
if ($webindex) {
info("Web Index: {$webindex}");
$p->setDefaultStub(null, $webindex);
}
}
}
if ($stub) {
info("Stub: {$stub}");
if (is_file($stub)) {
$stub = file_get_contents($stub);
}
$p->setStub($stub);
}
$p->stopBuffering();
info("Files: {$p->count()}");
} catch (\Exception $e) {
error($e->getMessage());
}