5

installing maatwebsite/excel with Laravel 9 but getting phpoffice and PHP version issues. I am using PHP 8.1, I downgrade to PHP 8.0 but still doesn't work. Even I enable the gd extention from the php.ini file.

I am installing maatwebsite using below command which is offered by official website

composer require maatwebsite/excel

enter image description here

Hadayat Niazi
  • 1,991
  • 3
  • 16
  • 28
  • Does this answer your question? [Laravel maatwebsite/excel composer install error in mac](https://stackoverflow.com/questions/58335105/laravel-maatwebsite-excel-composer-install-error-in-mac) – Mark Rotteveel Jun 16 '22 at 10:49
  • 1
    Please share more details, like the error message in text form, and your attempts to resolve the problem – Nico Haase Jun 17 '22 at 12:46

2 Answers2

9

I found the problem it's happening due to cache problem, we need to update the cache version.

Let me explain it with all steps

  1. Go to the php.ini file and remove ;

before

;extension=gd

after

extension=gd
  1. execute the command to change your cache
composer require psr/simple-cache ^2.0

if the above version is not work for you try it with 1.0 version (optional)

composer require psr/simple-cache ^1.0

Then install maatwebsiteexcel

composer require maatwebsite/excel

It will work like a charm

Hadayat Niazi
  • 1,991
  • 3
  • 16
  • 28
4

This will help you

composer require psr/simple-cache:^1.0 maatwebsite/excel

Some time composer require fails on Laravel 9 because of the simple-cache dependency, you will have to specify the psr/simple-cache version as ^1.0 in your composer.json to satisfy the PhpSpreadsheet dependency.

find solution here https://docs.laravel-excel.com/3.1/getting-started/installation.html

  • Please add some explanation to your answer such that others can learn from it. Requiring these two packages has already been recommended in the other answer, so what's the point in duplicating that other answer? – Nico Haase Jun 27 '22 at 11:20
  • sure, as I found this statement in given link that Some time composer require fails on Laravel 9 because of the simple-cache dependency, you will have to specify the psr/simple-cache version as ^1.0 in your composer.json to satisfy the PhpSpreadsheet dependency. – Toqeer Haider Jun 28 '22 at 03:51
  • Please add all clarification **to your answer** by editing it – Nico Haase Jun 28 '22 at 11:39