stopBuffering() is used in conjunction with the startBuffering() method. startBuffering() can provide a significant performance boost when creating or modifying a Phar archive with a large number of files. Ordinarily, every time a file within a Phar archive is created or modified in any way, the entire Phar archive will be recreated with the changes. In this way, the archive will be up-to-date with the activity performed on it.
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 startBuffering()/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
bar.phar Phar archive.
$p = new Phar(dirname(__FILE__) . '/brandnewphar.phar', 0, 'brandnewphar.phar');
$p['file1.txt'] = 'hi';
include 'phar://brandnewphar.phar/' . str_replace('_', '/', \$class) . '.php';
The above example will output:
string(24) "<?php __HALT_COMPILER();"
include 'phar://' . str_replace('_', '/', $class);