Is it possible to modify the behavior of a PHP script to write Zip files directly to disk instead of loading everything into memory?

When working with large Zip files in PHP, it is possible to modify the behavior of the script to write the Zip files directly to disk instead of loading everything into memory. This can help prevent memory exhaustion errors when dealing with large files. To achieve this, you can use the `ZipArchive` class in PHP to create a new Zip file on disk and add files to it without loading them into memory.

$zip = new ZipArchive();
$zipFileName = 'example.zip';

if ($zip->open($zipFileName, ZipArchive::CREATE) === TRUE) {
    $file1 = 'path/to/file1.txt';
    $file2 = 'path/to/file2.txt';

    $zip->addFile($file1, 'file1.txt');
    $zip->addFile($file2, 'file2.txt');

    $zip->close();
    echo 'Zip file created successfully.';
} else {
    echo 'Failed to create Zip file.';
}