I have face this problem to install maatwebsite/excel on laravel 8. How can I fix it?
NB: PHP version running 8.

- 310
- 2
- 4
- 14
-
It looks like it needs to install phpoffice/phpspreadsheet, which needs the gd extension installed for PHP – aynber May 17 '21 at 16:51
-
1Please share more details, like the error message in text form and your attempts to resolve the problem – Nico Haase May 18 '21 at 09:03
-
Did you fix this? What was the problem? – amrezzd May 21 '21 at 18:38
-
1@amirz98 the problem is listed in the error message, and solving that is ask so often on SO that it should not be too hard to find solutions – Nico Haase May 21 '21 at 20:30
8 Answers
I solved the problem with
- I just enable PHP
gd extension
fromphp.ini
file - installing PHP package
PhpSpreadsheet

- 310
- 2
- 4
- 14
I have just used composer require maatwebsite/excel -W --ignore-platform-req=ext-zip
and this has worked for me on linux ubuntu 20 with php 8.1

- 4,093
- 4
- 22
- 32

- 21
- 2
The problem is about Laravel Excel requirements. It seems PhpSpreadsheet: ^1.15
is not installed. Here is the list of requirements for Laravel-Excel 3.1,
PHP: ^7.2\|^8.0
Laravel: ^5.8
PhpSpreadsheet: ^1.15
PHP extension php_zip enabled
PHP extension php_xml enabled
PHP extension php_gd2 enabled
PHP extension php_iconv enabled
PHP extension php_simplexml enabled
PHP extension php_xmlreader enabled
PHP extension php_zlib enabled
Make sure these are installed and enabled on your php.ini
. Also make sure your php version on composer.json
is set like this:
"require": {
"php": "^7.2|^8.0",
},
Instead of something like this "php": ">=7.2"
. Check this out for more information. Please let me know if it worked.

- 1,787
- 15
- 38
-
Please share more details. Why should it be relevant to change the PHP requirements in the `composer.json`? Does this have any influence when set in an application's configuration? – Nico Haase May 21 '21 at 20:31
-
@NicoHaase It might be about compatibility issue mentioned [here](https://github.com/composer/composer/issues/9529#issuecomment-774506349), that is why I suggested to try changing the version. – amrezzd May 22 '21 at 04:07
I just want share another answer related here. If you run on unix (linux), try install php-gd using command line. Try check other answer related to your system.
sudo apt-get update
sudo apt-get install php8.0-gd
related:
How to install PHP GD in Ubuntu
If you using windows. Use this command.
composer require maatwebsite/excel --ignore-platform-reqs
This problem happen only on php 8.x! perhaps on lastest php 7. The problem same as above and still failed even php-gd is active. When type
composer require maatwebsite/excel
the error still the same. When checking using
php -i
(basicly same as phpinfo in console). We can see php gd is active. This answer is not recommended at the moment. Fixed still on the way related to this issue.
related link:
https://github.com/Maatwebsite/Laravel-Excel/discussions/3191
PHP8 is supported, make sure to use 3.1.30 of the package as mention above. To see other issue, please read this link.

- 51
- 3
-
this solution aims to not downgrade php. As of this mention on github, improvements are being made related to php 8 new behaviour – user2905554 Oct 03 '21 at 16:59
I solved using
Enable zip and gd extension in php.ini
or install using sudo apt-get install php8.0-gd
sudo apt-get install php8.0-zip
use composer require maatwebsite/excel:^3.1 -W
-W is for with-all-dependencies

- 1
- 3
delete composer.lock (json) then run below command
composer require phpoffice/phpspreadsheet
composer require maatwebsite/excel
it is working

- 11
- 1
-
2As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Nov 26 '21 at 06:17
-
Deleting the whole `composer.json` sounds like a bad idea. Could you even explain how this should magically resolve the given errors? – Nico Haase Nov 26 '21 at 06:51
-
Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Nov 26 '21 at 12:44
I used this command from composer tips and this my case is solved: "composer require maatwebsite/excel:*"

- 1
- 1
-
Please don't post duplicated answers, unless you want to share new insights. If this is the case here, please add some explanation to your answer such that others can learn from it – Nico Haase Mar 15 '23 at 14:03
In composer.json change the require "maatwebsite/excel": "1.1" or something into "maatwebsite/excel": "1.*" then run this command
"composer update"
into your root directory or project folder
-
v1 of that package is pretty outdated. It has seen its latest release in 2017, and I highly doubt that it is compatible with PHP 8 after all. Also, it requires Laravel v4 or v5, and this means it won't work with Laravel v8 – Nico Haase May 30 '23 at 06:24