CodeIgniter Forums
ZipArchive: class not found - Printable Version

+- CodeIgniter Forums (
+-- Forum: CodeIgniter 4 (
+--- Forum: CodeIgniter 4 Support (
+--- Thread: ZipArchive: class not found (/thread-74928.html)

ZipArchive: class not found - Olivier85 - 11-26-2019

I can't use the ZipArchive class in CI 4.0.0-rc.3, I can't find out a solution...
Thanks in advance for your support!

[Image: Deepin-Capture-cran-zone-de-s-lection-20...161136.png]

RE: ZipArchive: class not found - ciadmin - 11-26-2019

There is no ZipArchive in CI4, nor in CI3.
You are trying to open \ZipArchive, but the error message shows it can't find app\Controllers\Back\ZipArchive, which doesn't feel right. Could this be a namespace problem?

RE: ZipArchive: class not found - Olivier85 - 11-26-2019

I just want to use the PHP ZipArchive class (
I got the same problem when removing the backslash : $zip = new ZipArchive();
I can't manage to use it with CI4, I got no problem with CI3.
Any idea?

RE: ZipArchive: class not found - MGatner - 11-26-2019

The problem is that the second reference to the ZipArchive class doesn’t have a prefix slash, so PHP thinks it is relative to the current namespace.

RE: ZipArchive: class not found - Poetawd - 11-26-2019

CI4 is awesome because you can use almost any library with it !

For working with ZIP Files I recommend this one:

It is AWESOME and has some great features !

It is very simple to make it work with CI4. Easier with composer !

Please tell me if you need help installing it.

Here is a example how to use the library:

PHP Code:
        $projectName 'Project';

$projectDirectory ROOTPATH '/../folder';

$zipComments 'Some Comments';

$zipFile = new \PhpZip\ZipFile();

        try {            

setPassword('12345'// set password for all entries
->outputAsAttachment(''); // output to the browser without saving to a file

} catch (\PhpZip\Exception\ZipException $e) {
// handle exception

This code will ZIP a entire folder, including sub-directories, set comments for the ZIP file, set a password and output it to browser without saving the file in server !

Awesome right ?