PhpSpreadSheet Class ZipArchive not found Error [duplicate] - php

This question already has answers here:
Fatal error: Class 'ZipArchive' not found in
(25 answers)
Closed 3 months ago.
I've just downloaded PhpSpreadsheet package via composer and I tried to generate an Excel spreadsheet. But all I get is an error "Class ZipArchive not found ". I work on Windows. In my localhost it is correctly generating excel. My localhost php version is 7.0.2 .But server Php Version is 5.6. I am not able to generate excel in server. I am getting "*Class ZipArchive not found" error.

I think you just need the PHP "zip" extension on your server...
If I understand well, your dev machine is on Windows. But your "production" machine is on... Linux?
If it's Debian :
apt-get install php-zip
If it's RedHat or whatever
yum install...

I update the Ubuntu 16.04 with php5.6 to Ubuntu 18.04 with php7.2.
Solved the same erorr with installing the php-zip as in the first post: sudo apt-get install php-zip, then restart the apache server: sudo service apache2 restart.

You have to reference ZipArchive in your PHP code:
use ZipArchive;

Related

ImageMagick module not available with this PHP installation on Laravel 5.4 with PHP 7

Currently, I have cloned a project. I have PHP 7 on Ubuntu 14.04 64-bit.
The ImageMagick library is installed using the following command
sudo apt-get install php-imagick
But when I try image manipulation through this library, it throws the following exception
(1/1) NotSupportedException
ImageMagick module not available with this PHP installation.
How can I install this software with the latest PHP version?
Note: I am using Laravel 5.4 in this project.
You have to add extension=imagick.so in your php.ini file.
Location:
You can do some thing like this for the fastest way:
php -i | grep 'php.ini'
The result is like that:
Loaded Configuration File => /usr/local/lib/php.ini
Or call <?php phpinfo(); ?> from some php file to get this information :)
PS: Source
I had the same problem on my computer, and what solved it was:
Instead of installing sudo apt install php-imagick, I installed sudo apt install php7.4-imagick (or whatever version your PHP installation is).
This, in combination with Maraboc's answer did the trick for me.

Installing php7 or newest version on ubuntu 14.0

firstly, i've installed php5 on my system, and i want to upgrade to php7.1 and
and then I download the source code from the official website, and I install it.
The installation process was success, when I checked with php -v, it displayed php7.1
But when I check with phpinfo(), it's still displays the oldest php version
how can it happen where there are two different php versions but not stack each other PHP Version 5.5.9-1ubuntu4.22
Now, the problem is how to use the latest php7.1 on my localhost
thanks beforely, i'm sorry if my questions is unexplicit
If you didn't install libapache2-mod-php7.1 yet, install it.
then deactivate the older php module:
sudo a2dismod php5
and activate the new module php7.1 in apache:
sudo a2enmod php7.1
And finally restart apache2:
sudo service apache2 restart
This is essentially a duplicate of this question which I answered earlier this week. See the accepted solution which will fix your problem.
PHP Parse error: syntax error, unexpected '?' in helpers.php 233
I also recommend just upgrading to Ubuntu 16.04 or 17.10 and using the main supported version instead of a PPA. Just my two cents.

PHP installation configure: error: Cannot find php_pdo_driver.h

So I have already installed Apache2 and Mysql on Linux Mint (the same as Ubuntu), Now I am trying to install PHP on Apache but I get a very strange error message :
configure: error: Cannot find php_pdo_driver.h.
I did some search on the Internet and I found out that these files were not embedded before in PHP, but they are now. I even checked for it myself in the PHP source folders and I found that specific file. Can anyone tell me what's the problem and how to solve it ?
actually PDO is included on PHP core.
You must install the PHP and MySQL bundled packages.
Use sudo apt-get install php5-mysql
you should check your php version, you must have php version 5 to load PDO.

MongoDB installation on Mac OS X 10.11, with MacPorts

I am trying to install MongoDB on my computer running Mac OS X 10.11 (El Capitan).
My Apache + PHP configuration was already working correctly.
I installed MongoDB and PHP drivers for MongoDB through MacPorts:
sudo port install mongodb
sudo port install php55-mongodb
Installation ran correctly.
I added mongodb.so file to the extensions loaded in the php.ini file:
extension=/opt/local/lib/php55/extensions/no-debug-non-zts-20121212/mongodb.so
When I run phpinfo() function in php file, mongodb extension seems to be loaded correctly:
I tried to test my connexion by initializing a MongoClient instance:
<?php
$mongoDB = new MongoClient();
var_dump($mongoDB);
?>
Unfortunately, I got a HTTP ERROR 500, and I got the following line in my Apache logs:
PHP Fatal error: Class 'MongoClient' not found in ...
Did I make something wrong ?
On most of site I saw you need to add the extension mongo.so and not mongodb.so in your php.ini.
If it's not solved your problem, I recommand you to install MongoDB Drive with PELC.
Run command line:
$ sudo pecl install mongo
And add this line to your php.ini:
extension=mongo.so
Doc php.net Mongo Installation
Finally found a solution to my problem.
As #neverpanic and #Zagonine made me understand, php-mongodb and php-mongo are not the same extension.
If you want to use old PHP driving classes, you should use php-mongo package instead of the very new php-mongodb.
Trying to install latest php-mongo extension, I had an other problem related to OpenSSL. To bypass it, I installed an old version of php-mongo extension:
sudo /usr/local/pear/bin/pecl install mongo-1.5.8
Hopefully it will help someone else.

Error installing MongoDb PHP driver with XAMPP on Max OS Lion

I get this error when i try to run following command
sudo pecl install mongo
Error:
...php_mongo.c:22:10: fatal error: 'php.h'
file not found
#include <php.h>
^
1 error generated.
make: *** [php_mongo.lo] Error 1
ERROR: `make' failed
I am new to MAC, please help me to resolve this and get Mongo Working with PHP.
I have installed MacPorts and autoconf
It seems, that you did not install the xampp "Developer Package", required to build additional php extension. You can download the "Developer Package" from:
http://www.apachefriends.org/en/xampp-macosx.html#849
This has already been answered.
Please follow the processes outlined in this answer - Install PECL on Mac OS X 10.6.
I followed the process outlined here http://akrabat.com/php/setting-up-php-mysql-on-os-x-10-7-lion/, referenced by the above Stackoverflow link and the process for install pear, followed by pecl and subsequently -
sudo pecl install mongo
works perfectly on OSX Lion.
You may need to modify the extensions in /etc/php.ini, however, this is explained in the output after you install the php mongo driver.
It took me the whole day to find this answer, I had tried everything, but this worked finally:
sudo C_INCLUDE_PATH=/usr/local/opt/openssl/include /Applications/XAMPP/xamppfiles/bin/pecl install mongodb
I found this article very helpful. Saved a lot of time after I wasted a lot of time to check other links. I did for MAMP and think will work for XAMPP too.
The thing is MAMP does not ship with all PHP sources to compile pecl mongo file and create mongo.so. All what you need is download php for respective version you are using. I was using php version 5.6.10. I checked php.net site that was having 5.6.13 version. I downloaded sources for this version from PhP.net. Executed "sudo pecl install mongo" again and it worked.

Categories