ZipArchive is not working in Extbase + typo3

When we create a new zips “$zip = new ZipArchive();”

However, we get always the following error message:

Fatal error: Class ‘TYPO3 \ .. \ Domain \ Repository \ ZipArchive’ not found in … / Classes / Domain / Repository / XXXRepository.php on line 143.

Zip works nicely on the server. A simple PHP script which zips a file running properly in server.

In Extbase we have to add backward slash [ \ ] infront of class name.

Following script should do the trick.

$zip = new \ZipArchive();

If you have any queries, please do not hesitate to contact me at Jainish Senjaliya