-1

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?

Alessio Cantarella
  • 5,077
  • 3
  • 27
  • 34
Henrik Petterson
  • 6,862
  • 20
  • 71
  • 155
  • 3
    You're calling from within the `LukeMadhanga` namespace, and ZipArchive exists in the __global__ namespace.... use `$zip = new \ZipArchive;` (and learn about [namespaces](http://www.php.net/manual/en/language.namespaces.php)) – Mark Baker Mar 23 '17 at 13:01

1 Answers1

3

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

$zip = new \ZipArchive;
roberto06
  • 3,844
  • 1
  • 18
  • 29