(PHP >= 8.0.0, PECL zip >= 1.17.0)
ZipArchive::registerProgressCallback — Register a callback to provide updates during archive close.
public ZipArchive::registerProgressCallback(float $rate, callable $callback): bool
Register a callback function to provide updates during archive close.
rateChange between each call of the callback (from 0.0 to 1.0).
callback This function will receive the current state as a float (from 0.0 to 1.0).
This example creates a ZIP file archive php.zip and show progression.
Example #1 Archive a file
$zip = new ZipArchive();
if ($zip->open('php.zip', ZipArchive::CREATE | ZipArchive::OVERWRITE)) {
$zip->addFile(PHP_BINARY, 'php');
$zip->registerProgressCallback(0.05, function ($r) {
printf("%d%%\n", $r * 100);
});
$zip->close();
} Note:
This function is only available if built against libzip ≥ 1.3.0.
© 1997–2025 The PHP Documentation Group
Licensed under the Creative Commons Attribution License v3.0 or later.
https://www.php.net/manual/en/ziparchive.registerprogresscallback.php