Fatal error: Class 'ZipArchive' not found in

后端 未结 20 1314
既然无缘
既然无缘 2020-11-27 03:39

I have a problem that I install \'Archive_Zip 0.1.1\' on Linux server, but when I try to run the script to create the zip file it gives the fatal error

<
相关标签:
20条回答
  • 2020-11-27 03:48

    I had the same issue with CentOS and cPanel installed server. I installed zipArchive package via cPanel and didn't worked as expected. After trying with so many fixes suggested each and everywhere just the below worked for me.

    First find the name for the correct package with the below command

    yum search zip |grep -i php
    

    Then use the below code.

    yum install your_zip_package_name_with_php_version
    

    In my case correct code to install zipArchive was

    yum install php-pecl-zip.x86_64
    

    I had the solution from this link. How can I inslatt zipArchive on PHP 7.2 with CentOS 7?

    And this installation somehow enabled that package too and it also restarted the effecting services and after the completion of the execution of the above code zipArchive issue was gone.

    0 讨论(0)
  • 2020-11-27 03:49

    For the ZipArchive class to be present, PHP needs to have the zip extension installed.

    See this page for installation instructions (both Linux and Windows).

    0 讨论(0)
  • 2020-11-27 03:49

    For PHP 7.x

    sudo apt-get install php-zip
    

    For PHP 5.x

    sudo apt-get install php5.x-zip
    // (for example sudo apt-get install php5.6-zip)
    

    And then restart the Apache server

    sudo service apache2 restart
    
    0 讨论(0)
  • 2020-11-27 03:49

    You need to check the PHP version

    If php version is 5.6 then , You need to install php5.7-zip

    sudo apt-get install php5.6-zip
    

    and then

    sudo service apache2 restart
    

    Hope it helps

    0 讨论(0)
  • 2020-11-27 03:51

    I'm not seeing it here, so I'd like to add that on Debian/Ubuntu you may need to enable the extension after installing the relative package. So:

    sudo apt-get install php-zip
    sudo phpenmod zip
    sudo service apache2 restart
    
    0 讨论(0)
  • 2020-11-27 03:52

    1) You should require your file with ZipArchive file.

    require 'path/to/file/ZipArchive.php';
    

    2) Or use __autoload method of class. In PHP 5 it is a greate method __autoload().

    function __autoload($class_name) {
        require_once $class_name . '.php';
    }
    
    $obj  = new MyClass1(); // creating an object without require.
    

    http://www.php.net/manual/en/language.oop5.autoload.php

    0 讨论(0)
提交回复
热议问题