Please note that the phar stream wrapper does not work with any glob.
When you decide to move your project to phar archives you need to consider this.
The following won't work:
<?php
glob('phar://some.phar/*');
new DirectoryIterator('glob://phar://some.phar/*');
?>
While the following will work:
<?php
new DirectoryIterator('phar://some.phar/');
?>Користење на Phar архиви: phar stream wrapper
Почист и полокален преглед на PHP референцата, со задржана структура од PHP.net и подобра читливост за примери, секции и белешки.
Користење на Phar архиви: phar stream wrapper
Референца за `phar.using.stream.php` со подобрена типографија и навигација.
Користење на Phar архиви: phar stream wrapper
The Phar stream wrapper fully supports fopen() Phar stream обвивката целосно поддржува unlink(), stat(), fstat(), fseek(), rename() за читање и пишување (не додавање), opendir() and rmdir() and mkdir().
и операции на директориумски стримови
<?php
$context = stream_context_create(array('phar' =>
array('compress' => Phar::GZ)),
array('metadata' => array('user' => 'cellog')));
file_put_contents('phar://my.phar/somefile.php', 0, $context);
?>
На phar Индивидуалното компресирање на датотеки и метаподатоците по датотека исто така може да се манипулираат во Phar архива користејќи контексти на стримови:
allow_url_fopen and
allow_url_include stream обвивката не работи на далечински датотеки, и не може да работи на далечински датотеки, и затоа е дозволена дури и кога
INI опциите се оневозможени.
Белешки од корисници 2 забелешки
Some Examples of how to use the stream wrapper would be really helpful.
My floundering attempts reveal only the following:
<?php
$p = new PharData(dirname(__FILE__).'/phartest.zip', 0,'phartest',Phar::ZIP) ;
$p->addFromString('testfile.txt',
'this is just some test text');
// This works
echo file_get_contents('phar://phartest.zip/testfile.txt');
//This Fails
file_put_contents('phar://phartest.zip/testfile.txt',
'Thist is text for testfile.txt');
$context = stream_context_create(
array('phar' =>array('compress' =>Phar::ZIP))
) ;
//This Fails
file_put_contents(
'phar://phartest.zip/testfile.txt',
'Thist is text for testfile.txt',0,$context);
// This works but only with 'r' readonly mode.
$f = fopen(
'phar://C:\\Inetpub\\wwwroot\\PACT\\test\\phartest.zip\\testfile.txt',
'r') ;
?>