Search code examples
phplaravelphpwordphpoffice

Class 'ZipArchive' not found in Laravel phpword


I have installed phpword package in my laravel project. Now when I try to read a docx file using this code

public function upload(Request $request){
    $file = $request->file('file');
    $phpWord = \PhpOffice\PhpWord\IOFactory::load($file);
    foreach($phpWord->getSections() as $section) {
        foreach($section->getElements() as $element) {
            if(method_exists($element,'getText')) {
                echo $element->getText() . "<br>";
            }
        }
    }
}

I am getting an error

Class 'ZipArchive' not found

/vendor/phpoffice/common/src/Common/XMLReader.php line no 54

zip already installed in my php. enter image description here


Solution

  • Please run command for cache clear and dump-autoload like php artisan config:cache and composer dump-autoload