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

j_watson's avatar

Laravel Excel trouble installing

I'm having trouble installing Laravel Excel.

When I use this composer require maatwebsite/excel I get the error Method Illuminate\Foundation\Application::share does not exist. when publishing. And when I use this composer require "maatwebsite/excel:^3.1" I get the following error Your requirements could not be resolved to an installable set of packages.

Problem 1 - Root composer.json requires maatwebsite/excel 3.1 -> satisfiable by maatwebsite/excel[3.1.0]. - maatwebsite/excel 3.1.0 requires php ^7.0 -> your php version (8.2.8) does not satisfy that requirement.```

I appreciate any help I can get.

1 like
14 replies
Tray2's avatar

I just did a quick test, and with Laravel 11.41.0, using PHP 8.3.16, composer 2.8.4.

laravel new excel-project

cd excel-project

composer require maatwebsite/excel

It worked just fine, no errors.

j_watson's avatar

@Tray2 I did too the error only shows up when I try to publish the configuration file \config\app.php file

Sinnbeck's avatar

@j_watson Look at the error again. Most likely it says a bit more than what you posted

Also you said it failed on install in the first post and now you say it fails on publishing the config file? Which is it?

j_watson's avatar

@Sinnbeck I tried installing it two ways:

  1. composer require maatwebsite/excel fails when I publish the config\app.php
  2. composer require "maatwebsite/excel:^3.1" fails when installing.

Here is the error message for the second option:

    - Root composer.json requires maatwebsite/excel 3.1 -> satisfiable by maatwebsite/excel[3.1.0].                                              
    - maatwebsite/excel 3.1.0 requires php ^7.0 -> your php version (8.2.12) does not satisfy that requirement.    ```                              
                                                                                                                 
Sinnbeck's avatar

@j_watson Not sure why number 2 fails. Maybe you have something wrong with your composer cache. You can try composer clear-cache

But if you already installed it without any errors using 1. then there might not be a point. So the error you are getting with 1. Isnt there more to the error ?

Based on your first post, it sounds like you are calling app()->share() or similar somewhere in your code. Try searching your files for share

j_watson's avatar

@Sinnbeck I think 2 fails quite frequently since they added it in their documentation. Afterwards, they suggest using composer require maatwebsite/excel which installs version 1.1. Which gives me this error Method Illuminate\Foundation\Application::share does not exist when I try to publish the app.php file

j_watson's avatar

@Sinnbeck the app()->share() error is referring to this function protected function bindClasses() { // Bind the format identifier $this->app['excel.identifier'] = $this->app->share(function($app) { return new FormatIdentifier($app['files']); }); } from file:///.../vendor/maatwebsite/excel/src/Maatwebsite/Excel/ExcelServiceProvider.php#L154

j_watson's avatar

@Sinnbeck

Sinnbeck's avatar

@j_watson Try the following

  1. Delete the vendor folder
  2. Change this line "maatwebsite/excel": "^1.1", to "maatwebsite/excel": "^3.1",
  3. Run composer update
1 like
j_watson's avatar

@Sinnbeck I'm still getting this error Method Illuminate\Foundation\Application::share does not exist.

j_watson's avatar

@Sinnbeck composer require maatwebsite/excel installed version 1.1 I tried upgrading to 3.48.1 but that share error keeps popping up even when I run composer run dev

Please or to participate in this conversation.