Phar::stopBuffering
(PHP >= 5.3.0, PECL phar >= 1.0.0)
Phar::stopBuffering — Stop buffering write requests to the Phar archive, and save changes to disk
Описание
void Phar::stopBuffering
( void
)
However, this can be unnecessary when simply creating a new Phar archive,
when it would make more sense to write the entire archive out at once.
Similarly, it is often necessary to make a series of changes and to ensure
that they all are possible before making any changes on disk, similar to the
relational database concept of transactions. The
Phar::startBuffering()/Phar::stopBuffering() pair
of methods is provided for this purpose.
Phar write buffering is per-archive, buffering active for the
foo.phar Phar archive does not affect changes
to the bar.phar Phar archive.
Errors/Exceptions
PharException is thrown if any problems are encountered
flushing changes to disk.
Примеры
Пример #1 A Phar::stopBuffering() example
<?php
$p = new Phar(dirname(__FILE__) . '/brandnewphar.phar', 0, 'brandnewphar.phar');
$p['file1.txt'] = 'hi';
$p->startBuffering();
var_dump($p->getStub());
$p->setStub("<?php
function __autoload(\$class)
{
include 'phar://brandnewphar.phar/' . str_replace('_', '/', \$class) . '.php';
}
Phar::mapPhar('brandnewphar.phar');
include 'phar://brandnewphar.phar/startup.php';
__HALT_COMPILER();");
$p->stopBuffering();
var_dump($p->getStub());
?>
Результат выполнения данного примера:
string(24) "<?php __HALT_COMPILER();"
string(195) "<?php
function __autoload($class)
{
include 'phar://' . str_replace('_', '/', $class);
}
Phar::mapPhar('brandnewphar.phar');
include 'phar://brandnewphar.phar/startup.php';
__HALT_COMPILER();"
Смотрите также
- Phar::startBuffering() - Start buffering Phar write operations, do not modify the Phar object on disk
- Phar::isBuffering() - Used to determine whether Phar write operations are being buffered, or are flushing directly to disk