title: PHP Zip Creating Class ZipArchive Not Found Error
body: <p>i'm trying to create a zip script based on what I've found <a href="https://stackoverflow.com/questions/1061710/php-zip-files-on-the-fly/" title="Here">here</a> but I seem to be getting a Fatal error: Class 'ZipArchive' not found error on the new ZipArchive(); function.</p>
  
  <p>Researching this it seems that this is usually due to the way PHP is compiled. I have a shared hosting account, so i've not configured any of this stuff...and I assume that I can't make any changes to the build. Out of interest I took a look in my phpinfo() and I found some things that looked associated:</p>
  
  <p>PHP Version 5.2.6</p>
  
  <pre><code>BZip2 Support   Enabled    &lt;--maybe not so relevant
  ZLib Support    enabled
  Stream Wrapper support  compress.zlib://
  Stream Filter support   zlib.inflate, zlib.deflate
  Compiled Version    1.1.4
  Linked Version  1.1.4 
  </code></pre>
  
  <p>I'm not entirly sure if any of this means that I have the ability to create zips.
  For further info (although I don't think it's relivent) here's my script so far....this is untested mind you as I can't get pased this Class not found error.</p>
  
  <pre><code>$file = tempnam("tmp", "zip");
  $zip = new ZipArchive();
  $zip-&gt;open($file, ZipArchive::OVERWRITE);
  
  
     //the string "file1" is the name we're assigning the file in the archive
  $zip-&gt;addFile('show1.jpg', 'file1.jpg');
  $zip-&gt;addFile('show2.jpg', 'file2.jpg');
  $zip-&gt;addFile('show3.jpg', 'file3.jpg');
  $zip-&gt;addFile('show4.jpg', 'file4.jpg');
  $zip-&gt;addFile('show5.jpg', 'file5.jpg');
  $zip-&gt;addFile('show6.jpg', 'file6.jpg');
  
  // echo $zip-&gt;file(); //this sends the compressed archive to the output buffer instead of writing it to a file.
  
  $zip-&gt;close();
  header('Content-Type: application/zip');
  header('Content-Length: ' . filesize($file));
  header('Content-Disposition: attachment; filename="' . $file.'"');
  readfile($file);
  unlink($file); 
  </code></pre>
  
  <p>So my question(s) really are:</p>
  
  <ol>
  <li>Am I doing anything in my script to cause this error?</li>
  <li>Does any of that stuff from my phpinfo() mean I should be able to create zip files, ..if not what should I be looking for in there that will let me know if i have the capability.</li>
  <li>It looks like this ZLib is some soft of library, but I've got no idea if it does what I want it do, or even how to use it....this is a bit of a hunch, but if it can help me create zip files can anyone point me in the right direction of how to use it?</li>
  </ol>
  
  <p>Thanks in advance.
  Dan</p>