title: Using ZipArchive with PHP 8 and temporary files
body: <p>PHP 8 changes how the &quot;open&quot; of a ZIP archive works and it is noted that:</p>
  <blockquote>
  <p>Using empty file as ZipArchive is deprecated. Libzip 1.6.0 do not accept empty files as valid zip archives any longer.</p>
  </blockquote>
  <p>In the test code below the opening of the ZIP file named <code>$backupzip</code> works without error but the opening of the ZIP file names <code>$invoicezip</code> fails with the error:</p>
  <blockquote>
  <p>Deprecated: ZipArchive::open(): Using empty file as ZipArchive is deprecated on line 12</p>
  </blockquote>
  <pre><code>&lt;?php
  declare(strict_types=1);
  ini_set('display_errors','1');ini_set('display_startup_errors','1');error_reporting(E_ALL);
      
  define('BACKUPDIR','E:\Database_Backups\\');
  $backupfile = BACKUPDIR . date('Ymd') . '.zip';
  $temp_file  = tempnam(sys_get_temp_dir(),'AW');
  
  $backupzip  = new ZipArchive();
  $invoicezip = new ZipArchive();
  
  $backupzip-&gt;open($backupfile,ZipArchive::CREATE);  // &lt;&lt;&lt;--- this works
  $invoicezip-&gt;open($temp_file,ZipArchive::CREATE);  // &lt;&lt;&lt;--- this fails
  </code></pre>