Installing php_zip on Linux


This is an error that I encountered with while using PHPExcel. It is a library written in pure PHP and providing a set of classes that allow us to write to and read from different spreadsheet file formats, like Excel (BIFF) .xls, Excel 2007 (OfficeOpenXML) .xlsx, CSV, Libre/OpenOffice Calc .ods, Gnumeric, PDF, HTML, etc. This library is built around Microsoft's OpenXML standard and PHP. The requirements of this library are :

  • PHP version 5.2.0 or higher
  • PHP extension php_zip enabled (required if you need PHPExcel to handle .xlsx .ods or .gnumeric files)
  • PHP extension php_xml enabled
  • PHP extension php_gd2 enabled (optional, but required for exact column width auto-calculation)

While I was working on a project, I didn't check if all dependencies for PHPExcel were met. I wrote the program. It was fine when I was writing to the old .xls file format but as I wanted to write for .xlsx I got this error. This error was a resultant of unmet dependency of php_zip.

Fatal error: Class 'ZipArchive' not found in/var/www/vhosts/example.com/httpdocs/nomina_virtual/Classes/PHPExcel/Writer/Excel2007.php on line 226
So how do we solve this issue. Its pretty simple with PECL which is a repository of PHP extension that are made available to us via the PEAR packaging system. The single step solution to this is

#pecl install zip
You just have to run this command in terminal and you'll have php_zip installed in your system with php_zip enabled in  php.ini automatically.

Comments

Popular posts from this blog

Automate file upload in Selenium IDE

How To Install and Configure Nextcloud