当前位置: 首页>>代码示例>>PHP>>正文


PHP Phar::addEmptyDir方法代码示例

本文整理汇总了PHP中Phar::addEmptyDir方法的典型用法代码示例。如果您正苦于以下问题:PHP Phar::addEmptyDir方法的具体用法?PHP Phar::addEmptyDir怎么用?PHP Phar::addEmptyDir使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Phar的用法示例。


在下文中一共展示了Phar::addEmptyDir方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: dirname

<?php

$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar';
$tname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.zip';
$alias = 'phar://hio';
$phar = new Phar($fname);
$phar['a.php'] = '<?php echo "This is a\\n"; include "' . $alias . '/b.php"; ?>';
$phar->setAlias('hio');
$phar->addEmptyDir('test');
$phar->stopBuffering();
copy($fname, $tname);
$phar->setAlias('hio2');
try {
    $p = new Phar($tname);
} catch (Exception $e) {
    echo $e->getMessage() . "\n";
}
?>
===DONE===
开发者ID:gleamingthecube,项目名称:php,代码行数:19,代码来源:ext_phar_tests_zip_exists_as_phar.php

示例2: dirname

<?php

$fname = dirname(__FILE__) . '/tempmanifest2.phar.php';
$pname = 'phar://' . $fname;
$phar = new Phar($fname);
$phar->setDefaultStub();
$phar->setAlias('fred');
$phar['file1.txt'] = 'hi';
$phar['file2.txt'] = 'hi2';
$phar['subdir/ectory/file.txt'] = 'hi3';
$phar->mount($pname . '/mount2', __FILE__);
$phar->addEmptyDir('one/level');
$phar->extractTo(dirname(__FILE__) . '/extract2', 'mount2');
$phar->extractTo(dirname(__FILE__) . '/extract2');
$out = array();
foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator(dirname(__FILE__) . '/extract2', 0x3000), RecursiveIteratorIterator::CHILD_FIRST) as $path => $file) {
    $extracted[] = $path;
}
sort($extracted);
foreach ($extracted as $out) {
    echo "{$out}\n";
}
?>
===DONE===
<?php 
@unlink(dirname(__FILE__) . '/tempmanifest2.phar.php');
$dir = dirname(__FILE__) . '/extract2/';
@unlink($dir . 'file1.txt');
@unlink($dir . 'file2.txt');
@unlink($dir . 'subdir/ectory/file.txt');
@rmdir($dir . 'subdir/ectory');
开发者ID:alphaxxl,项目名称:hhvm,代码行数:31,代码来源:phar_extract2.php

示例3: dirname

<?php

$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
$phar = new Phar($fname);
$phar['a/b'] = 'file contents
this works';
$phar->addEmptyDir('hi');
echo $phar['a/b']->getContent() . "\n";
try {
    echo $phar['a']->getContent(), "\n";
} catch (Exception $e) {
    echo $e->getMessage(), "\n";
}
try {
    echo $phar['hi']->getContent(), "\n";
} catch (Exception $e) {
    echo $e->getMessage(), "\n";
}
?>
===DONE===
<?php 
error_reporting(0);
unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php');
__halt_compiler();
?>
开发者ID:badlamer,项目名称:hhvm,代码行数:25,代码来源:phar_oo_getcontents.php

示例4: file_get_contents

<?php

$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.zip';
$alias = 'phar://' . $fname;
$phar = new Phar($fname);
$phar->setStub("<?php\nPhar::mapPhar('hio');\n__HALT_COMPILER(); ?>");
$phar->addEmptyDir('a');
$phar['a/x'] = 'a';
$phar->stopBuffering();
include $fname;
echo file_get_contents($alias . '/a/x') . "\n";
var_dump(rmdir($alias . '/a'));
echo file_get_contents($alias . '/a/x') . "\n";
unlink($alias . '/a/x');
var_dump(rmdir($alias . '/a'));
error_reporting(0);
unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.zip');
开发者ID:badlamer,项目名称:hhvm,代码行数:17,代码来源:rmdir.php

示例5: dirname

<?php

$fname = dirname(__FILE__) . '/tempmanifest1.phar.php';
$pname = 'phar://' . $fname;
$a = new Phar($fname);
$a['file1.txt'] = 'hi';
$a['file2.txt'] = 'hi2';
$a['subdir/ectory/file.txt'] = 'hi3';
$a->mount($pname . '/mount', __FILE__);
$a->addEmptyDir('one/level');
$a->extractTo(dirname(__FILE__) . '/extract', 'mount');
$a->extractTo(dirname(__FILE__) . '/extract');
$out = array();
foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator(dirname(__FILE__) . '/extract', 0x3000), RecursiveIteratorIterator::CHILD_FIRST) as $p => $b) {
    $out[] = $p;
}
sort($out);
foreach ($out as $b) {
    echo "{$b}\n";
}
$a->extractTo(dirname(__FILE__) . '/extract1', 'file1.txt');
var_dump(file_get_contents(dirname(__FILE__) . '/extract1/file1.txt'));
$a->extractTo(dirname(__FILE__) . '/extract1', 'subdir/ectory/file.txt');
var_dump(file_get_contents(dirname(__FILE__) . '/extract1/subdir/ectory/file.txt'));
$a->extractTo(dirname(__FILE__) . '/extract1-2', array('file2.txt', 'one/level'));
var_dump(file_get_contents(dirname(__FILE__) . '/extract1-2/file2.txt'));
var_dump(is_dir(dirname(__FILE__) . '/extract1-2/one/level'));
try {
    $a->extractTo(dirname(__FILE__) . '/whatever', 134);
} catch (Exception $e) {
    echo $e->getMessage(), "\n";
开发者ID:zaky-92,项目名称:php-1,代码行数:31,代码来源:ext_phar_tests_phar_extract.php

示例6: mkdir

 /**
  * Create an internal directory, creating parent directories as needed
  *
  * @param string $dir
  */
 function mkdir($dir)
 {
     $this->phar->addEmptyDir($dir);
 }
开发者ID:peopleplan,项目名称:Pyrus,代码行数:9,代码来源:Phar.php

示例7: dirname

<?php

$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
$pname = 'phar://' . $fname;
Phar::interceptFileFuncs();
mkdir('phar://');
mkdir('phar://foo.phar');
$a = new Phar($fname);
$a['a'] = 'hi';
mkdir($pname . '/a');
rmdir('phar://');
rmdir('phar://foo.phar');
rmdir($pname . '/a');
$a->addEmptyDir('bb');
$a->addEmptyDir('bb');
try {
    $a->addEmptyDir('.phar');
} catch (Exception $e) {
    echo $e->getMessage(), "\n";
}
?>
===DONE===
<?php 
error_reporting(0);
unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php');
__halt_compiler();
?>
开发者ID:badlamer,项目名称:hhvm,代码行数:27,代码来源:mkdir.php

示例8: RecursiveIteratorIterator

 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *     http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
LICENSE;
$file = 'psx-' . VERSION . '.phar';
$dir = new RecursiveIteratorIterator(new RecursiveDirectoryIterator(PATH), RecursiveIteratorIterator::SELF_FIRST);
$phar = new Phar($file, 0, $file);
$phar->setMetadata($license);
foreach ($dir as $file) {
    $path = (string) $file;
    $name = substr($path, 12);
    // remove psx/library/ from path
    if ($file->isFile()) {
        $phar->addFromString($name, php_strip_whitespace($path));
    } else {
        if ($file->isDir() && $file->getFilename() != '.' && $file->getFilename() != '..') {
            $phar->addEmptyDir($name);
        }
    }
    echo 'A ' . $name . "\n";
}
开发者ID:seytar,项目名称:psx,代码行数:31,代码来源:generate-phar.php

示例9: catch

    $a->copy('a', 'b');
} catch (Exception $e) {
    echo $e->getMessage() . "\n";
}
$a->offsetExists(array());
$a->offsetGet(array());
ini_set('phar.readonly', 0);
$a->offsetSet(array());
ini_set('phar.readonly', 1);
$b->offsetUnset(array());
try {
    $a->offsetUnset('a');
} catch (Exception $e) {
    echo $e->getMessage() . "\n";
}
$a->addEmptyDir(array());
$a->addFile(array());
$a->addFromString(array());
try {
    $a->setMetadata('a');
} catch (Exception $e) {
    echo $e->getMessage() . "\n";
}
ini_set('phar.readonly', 0);
$a->setMetadata(1, 2);
ini_set('phar.readonly', 1);
try {
    $a->delMetadata();
} catch (Exception $e) {
    echo $e->getMessage() . "\n";
}
开发者ID:zaky-92,项目名称:php-1,代码行数:31,代码来源:ext_phar_tests_badparameters.php

示例10: RecursiveIteratorIterator

 $iterator = new RecursiveIteratorIterator($iterator, RecursiveIteratorIterator::SELF_FIRST);
 if ($options['exclude_files'] || $options['exclude_dirs']) {
     $iterator = new ExcludeFilesIterator($iterator, $options['exclude_files'], $options['exclude_dirs']);
 }
 // buildFromIterator unfortunately sucks and skips nested directories (?)
 foreach ($iterator as $file) {
     if (!$iterator->isDot()) {
         if (!QUIET_MODE) {
             echo "adding " . $file . PHP_EOL;
         }
         if ($file->isFile()) {
             $phar->addFile($file, strip_from_beginning($options['src'], $file));
         }
         if ($file->isDir()) {
             // this also doesn't work :(
             $phar->addEmptyDir(strip_from_beginning($options['src'], $file));
         }
     }
 }
 //$phar->buildFromIterator($iterator, $options['src']);
 // unfortunately Phar disables openssl signing for compressed archives
 // $phar->compress(PHAR::GZ);
 if ($options['stub']) {
     if (!QUIET_MODE) {
         echo "Setting stub from {$options['stub']}" . PHP_EOL;
     }
     $phar->setStub(file_get_contents($options['stub']));
 }
 if (!$options['nosign']) {
     // apply the signature
     if (!QUIET_MODE) {
开发者ID:holdensmagicalunicorn,项目名称:phar-util,代码行数:31,代码来源:phar-build.php

示例11: compressDirectory

 /**
  * Compresses a directory into the archive
  * @param \Phar $archive Phar object of PHP
  * @param zibo\library\filesystem\File $dir The directory to compress in the archive
  * @param zibo\library\filesystem\File $prefix The path for the directory in the archive
  * @return null
  */
 private function compressDirectory(PhpPhar $archive, File $dir, File $prefix)
 {
     $children = $dir->read();
     if (empty($children)) {
         $archive->addEmptyDir(new File($prefix->getPath(), $dir->getName()));
     } else {
         foreach ($children as $file) {
             $this->compressFile($archive, $file, $prefix);
         }
     }
 }
开发者ID:BGCX261,项目名称:zibo-svn-to-git,代码行数:18,代码来源:Phar.php

示例12: dirname

<?php

$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar';
$phar = new Phar($fname);
$phar['long/path/name.txt'] = 'hi';
$phar->addEmptyDir('long/path');
?>
===DONE===
<?php 
unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar');
开发者ID:alphaxxl,项目名称:hhvm,代码行数:10,代码来源:bug46178.php

示例13: RecursiveIteratorIterator

exec("rm chive/yii/web/js/source/treeview -rf");
exec("rm chive/yii/web/js/source/yiitab -rf");
exec("rm chive/yii/web/js/source/jquery.js");
exec("rm chive/yii/web/widgets/captcha -rf");
exec("rm chive/yii/zii -rf");
// Add all files
$sourceDir = __DIR__ . "/chive";
$i = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($sourceDir), RecursiveIteratorIterator::SELF_FIRST);
foreach ($i as $file) {
    $basename = basename($file);
    if ($basename[0] == ".") {
        continue;
    }
    $targetPath = substr($file, strlen($sourceDir) + 1);
    if (is_dir($file)) {
        $phar->addEmptyDir($targetPath);
    } elseif (!substr_compare($file, ".php", -4)) {
        // Get content
        echo "- Adding PHP " . $file . "\n";
        $content = php_strip_whitespace($file);
        $content = str_replace("realpath(", "ltrim(", $content);
        file_put_contents($file, $content);
        $phar->addFile($file, $targetPath);
    } elseif (!substr_compare($file, ".js", -3)) {
        echo "- Adding JS " . $file . "\n";
        exec("./jsmin <" . $file . " >" . $file . ".min");
        unlink($file);
        $phar->addFile($file . ".min", $targetPath);
    } elseif (!substr_compare($file, ".xml", -4) && strpos($file, $sourceDir . "/protected/messages/") === 0) {
        echo "- Adding XML " . $file . "\n";
        $content = gzcompress(file_get_contents($file), 9);
开发者ID:cebe,项目名称:chive,代码行数:31,代码来源:pharExport.php

示例14: createPharArchive

 public static function createPharArchive($arg, $origin_dir, $archive_file, $stub = null, $web_stub = null, $overwrite = false)
 {
     if (!extension_loaded('phar')) {
         throw new pakeException(__CLASS__ . ' module requires "phar" extension');
     }
     if (false === $overwrite and file_exists($archive_file)) {
         return true;
     }
     if (!self::endsWith($archive_file, '.phar')) {
         throw new pakeException("Archive must have .phar extension");
     }
     $files = pakeFinder::get_files_from_argument($arg, $origin_dir, true);
     pake_echo_action('file+', $archive_file);
     try {
         $arc = new Phar($archive_file);
         foreach ($files as $file) {
             $full_path = $origin_dir . '/' . $file;
             pake_echo_action('phar', '-> ' . $file);
             if (is_dir($full_path)) {
                 $arc->addEmptyDir($file);
             } else {
                 $arc->addFile($full_path, $file);
             }
         }
         if (null !== $stub) {
             pake_echo_action('phar', '[stub] ' . $stub . (null === $web_stub ? '' : ', ' . $web_stub));
             $arc->setStub($arc->createDefaultStub($stub, $web_stub));
         }
     } catch (PharException $e) {
         unset($arc);
         pake_remove($archive_file);
         throw $e;
     }
 }
开发者ID:otis22,项目名称:reserve-copy-system,代码行数:34,代码来源:pake.php


注:本文中的Phar::addEmptyDir方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。