Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

enadabuzaid's avatar

laravel excel not working

I am installed the laravel excel via sail composer ( because I am using Laravel 10 installed via sail )

when putting this

'providers' => ServiceProvider::defaultProviders()->merge([
     /*
       * Package Service Providers...
       */
  Maatwebsite\Excel\ExcelServiceProvider::class,

        .
		.
		.
		.
])->toArray(),

I get this error

 BadMethodCallException 

  Method Illuminate\Foundation\Application::share does not exist.


also when run this

composer show maatwebsite/excel

or run

sail composer show maatwebsite/excel     

the result like this

name     : maatwebsite/excel
descrip. : An eloquent way of importing and exporting Excel and CSV in Laravel 4 with the power of PHPExcel
keywords : PHPExcel, batch, csv, excel, export, import, laravel
versions : * v1.1.5
type     : library
license  : LGPL
homepage : 
source   : [git] https://github.com/Maatwebsite/Laravel-Excel.git 0c67aba8387726458d42461eae91a3415593bbc4
dist     : [zip] https://api.github.com/repos/Maatwebsite/Laravel-Excel/zipball/0c67aba8387726458d42461eae91a3415593bbc4 0c67aba8387726458d42461eae91a3415593bbc4
path     : /var/www/html/vendor/maatwebsite/excel
names    : maatwebsite/excel

support
issues : https://github.com/Maatwebsite/Laravel-Excel/issues
source : https://github.com/Maatwebsite/Laravel-Excel/tree/master

autoload
psr-0
Maatwebsite\Excel\ => src/
classmap
src/Maatwebsite/Excel, tests/TestCase.php

requires
php >=5.3.0
phpoffice/phpexcel ~1.8.0

requires (dev)
mockery/mockery ~0.9
orchestra/testbench ~2.2.0@dev
phpunit/phpunit ~4.0

0 likes
2 replies
LaryAI's avatar
Level 58

The error message "Method Illuminate\Foundation\Application::share does not exist" suggests that the version of Laravel being used is not compatible with the version of Laravel Excel being installed. Laravel Excel v1.1.5 is only compatible with Laravel 5.1 to 5.5. If you are using Laravel 6 or higher, you should use Laravel Excel v3 or higher.

To fix the issue, you can try installing a compatible version of Laravel Excel. For example, if you are using Laravel 6, you can install Laravel Excel v3 by running the following command:

composer require maatwebsite/excel:^3.1

Then, add the service provider to your config/app.php file:

'providers' => [
    // ...
    Maatwebsite\Excel\ExcelServiceProvider::class,
],

If you are still having issues, you can try clearing the cache by running the following command:

php artisan cache:clear

You can also try running the following command to publish the config file:

php artisan vendor:publish --provider="Maatwebsite\Excel\ExcelServiceProvider" --tag=config

This will create a config/excel.php file that you can customize to fit your needs.

If none of these solutions work, you can try posting a question on the Laracasts forum or opening an issue on the Laravel Excel GitHub repository.

gerrz's avatar

For laravel 10 and sail I use this command and it worked for me: composer require maatwebsite/excel:^3.1.48 -w

1 like

Please or to participate in this conversation.