I have a problem when I execute following command.
php artisan db:seed --class=QuestionTableSeeder
The error message is as follows.
Symfony\Component\Debug\Exception\FatalThrowableError : Class 'ZipArchive' not found
at /var/www/csi/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xlsx.php:338 334| $excel->removeCellXfByIndex(0); // remove the default style 335| } 336| $unparsedLoadedData = []; 337|
338| $zip = new ZipArchive(); 339| $zip->open($pFilename); 340| 341| // Read the theme first, because we need the colour scheme when reading the styles 342| //~ http://schemas.openxmlformats.org/package/2006/relationships"
Exception trace:
1
PhpOffice\PhpSpreadsheet\Reader\Xlsx::load("/tmp/laravel-excel-8wjCLq8hS4qVk49C5Rg30jkE6zVErU01.xlsx") /var/www/csi/vendor/maatwebsite/excel/src/Reader.php:2292 Maatwebsite\Excel\Reader::readSpreadsheet() /var/www/csi/vendor/maatwebsite/excel/src/Reader.php:215
Please use the argument -v to see more details.
The class QuestionTableSeeder is following.
<?php
use App\Imports\QuestionImport;
use App\ORM\Question;
use Illuminate\Database\Seeder;
use Maatwebsite\Excel\Facades\Excel;
class QuestionTableSeeder extends Seeder
{
public function run(): void
{
DB::statement('set foreign_key_checks=0');
Question::truncate();
DB::statement('set foreign_key_checks=1');
Excel::import(new QuestionImport(), 'database/seeds/data/questions.xlsx');
}
}
Please tell me the solution. What should I do to resolve the problem? I have installed php7.3-zip and php73-php-pecl-zip, then also restarted Apache but still it doesn't work.
The versions are following;
- PHP : 7.3
- Laravel : 6.6.0
- maatwebsite/excel : 3.1.17
- mysql Ver 15.1 : Distrib 5.5.64-MariaDB, for Linux (x86_64) using readline 5.1
- CentOS Linux : release 7.7.1908 (Core)