5

I am having a rough time trying to install the Laravel Excel (http://www.maatwebsite.nl/laravel-excel/docs) package to my Laravel 5. Here's what I've done so far:

  • Added "maatwebsite/excel": "2.*" to my require, composer update finishes just fine and I have all the package files
  • Added 'Maatwebsite\Excel\ExcelServiceProvider', to providers array
  • Added 'Excel' => 'Maatwebsite\Excel\Facades\Excel', to aliases array

Here's the problem - when I try running php artisan vendor:publish, it tells me Nothing to publish for tag [].

When I use php artisan tinker and run $excel = App::make('excel'), it tells me ReflectionException with message 'Class excel does not exist'.

What am I doing wrong?

pnuts
  • 58,317
  • 11
  • 87
  • 139
Salkz
  • 1,062
  • 9
  • 17
  • Did you try to run `composer dumpautoload` and then publish again? – lesssugar Jul 18 '15 at 13:12
  • @lesssugar yes, I tried that. – Salkz Jul 18 '15 at 13:16
  • I've just tried installing the package both on Laravel 5.0.* and Laravel 5.1.* and it worked just fine for both, so perhaps the problem is specific to your environment. – Bogdan Jul 18 '15 at 13:19
  • try `artisan vendor:publish --tag=config` – NaN Jul 18 '15 at 13:42
  • @NaN `Nothing to publish for tag [config].` – Salkz Jul 18 '15 at 13:44
  • hmm can you confirm you have the file` /vendor/maatwebsite/excel/src/config/excel.php`? If you do, just copy that file into your config directory as that is all the publish command does anyway – NaN Jul 18 '15 at 13:46
  • Copied, but that doesn't fix my error related to Laravel not finding the class. :( – Salkz Jul 18 '15 at 13:49
  • @NAN Publishing the configuration file is not a requirement for the package to work, it's only there so you can adjust a the configuration if needed, without actually editing the vendor specific copy of the config file. Salkz please try setting up a fresh installation of Laravel and installing the package there. This should at least determine if the problem is specific to the app you're currently working with or if it is a general enviroment issue. – Bogdan Jul 18 '15 at 13:49
  • @Bogdan Thanks, I will try and post an update later. – Salkz Jul 18 '15 at 13:51
  • I've had both errors in the past with a package and they had to do with me forgetting to add the lines to the `providers` array and the `aliases` array. Probably a stupid question, but are you sure you put them in the right spot? What file did you put them in? – Björn Jul 18 '15 at 22:19
  • Also can you check if `Maatwebsite\Excel\ExcelServiceProvider` and `Maatwebsite\Excel\Facades\Excel` classes are in `vendor/composer/autoload_classmap.php`? – Björn Jul 18 '15 at 22:24
  • @Björn I put them into `config/app.php` and yes - the classes are in `vendor/composer/autoload_classmap.php`. – Salkz Jul 19 '15 at 10:03
  • @Bogdan I set up a new VM, did everything as before and it works. My guess is that I originally configured something while being root and the permissions are wrong somewhere... – Salkz Jul 19 '15 at 11:29

1 Answers1

9

I was facing the same problem and came to this question but there wasn't any clear solution. So I keep searching and found a simple solution.

The problem is related with the cached config file. So for Laravel 5.1, just clear the cache

php artisan config:cache

and it worked perfectly in my case. Source

Ariful Haque
  • 3,662
  • 5
  • 37
  • 59