Henrik Petterson Henrik Petterson -4 years ago 70
PHP Question

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?

Answer Source

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

$zip = new \ZipArchive;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download