• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
ZipArchive: class not found

#1
Hello,
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]
Reply

#2
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?
Reply

#3
I just want to use the PHP ZipArchive class (https://www.php.net/manual/en/class.ziparchive.php).
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?
Reply

#4
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.
Reply

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

For working with ZIP Files I recommend this one: https://github.com/Ne-Lexa/php-zip

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 {            

            
$zipFile
                
->addDirRecursive($projectDirectory)
                ->
setArchiveComment($zipComments)
                ->
setPassword('12345'// set password for all entries
                
->outputAsAttachment('filename.zip'); // 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 ?
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.