To install the maatwebsite/excel latest version in Laravel 11 which is using PHP 8.2 version we need to follow some steps.
1. If you are using xampp, wampp, or running this on any server please enable extension=gd from your php.ini.
2. run
composer require maatwebsite/excel:^3.1
3. If installing you receive the following error
Run
composer require maatwebsite/excel:^3.1.55
Might be you get this error
Error: maatwebsite/excel 3.1.55 requires phpoffice/phpspreadsheet ^1.18 -> found phpoffice/phpspreadsheet[1.18.0, …, 1.29.0] but it conflicts with your root composer.json require (^2.2).
In this case, you need phpoffice/phpspreadsheet ^1.18. For this
Run
composer require phpoffice/phpspreadsheet:^1.18 --with-all-dependencies
this will install phpoffice/phpspreadsheet:^1.18 version which require by maatwebsite/excel:^3.1.55.
Now you Run
composer require maatwebsite/excel:^3.1.55
This way you can install the maatwebsite/excel 3.1 in Laravel 11. Please comment if you are getting any issue, thank you.
Reference:
https://packagist.org/packages/maatwebsite/excel#3.1.55
https://docs.laravel-excel.com/3.1/getting-started/installation.html