Search code examples
phpphp-ziparchive

Can't call the ZipArchive class


I have ZipArchive enabled, the PHP extension. In my class, when I run:

$zip = new ZipArchive;

I get this error:

Fatal error: Class 'LukeMadhanga\ZipArchive' not found

I am guessing the problem is how I call ZipArchive? Or a namespace issue?


Solution

  • It indeed looks like a namespace issue, you need to access your ZipArchive class from the global namespace :

    $zip = new \ZipArchive;