Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel Excel Installation

I've just used composer to get Maatwebsite Laravel-Excel. I am about to use it but I am brand new to installing/using packages. So far I've only used what is shipped with Laravel. I'm reading the documentation and am following the steps (I've done the first three steps) but I am confused by this line;

The class is binded to the ioC as excel

$excel = App::make('excel');

I don't really know what most of that means. I have read up a little on ioC and then Dependency Injection (also new to me). But I still don't know - is this part of the docs telling me to do something?? I ran php artisan on the command line (for another purpose) and I got this back;

[2015-04-23 13:42:09] local.ERROR: exception 'BadMethodCallException' with message 'Call to undefined method [package]' in /vagrant/source/laravel-excel/vendor/laravel/framework/src/Illuminate/Support/ServiceProvider.php:226
Stack trace:
#0 /vagrant/source/laravel-excel/vendor/maatwebsite/excel/src/Maatwebsite/Excel/ExcelServiceProvider.php(45): Illuminate\Support\ServiceProvider->__call('package', Array)
#1 /vagrant/source/laravel-excel/vendor/maatwebsite/excel/src/Maatwebsite/Excel/ExcelServiceProvider.php(45): Maatwebsite\Excel\ExcelServiceProvider->package('maatwebsite/exc...')
#2 [internal function]: Maatwebsite\Excel\ExcelServiceProvider->boot()
#3 /vagrant/source/laravel-excel/vendor/laravel/framework/src/Illuminate/Container/Container.php(523): call_user_func_array(Array, Array)
#4 /vagrant/source/laravel-excel/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(703): Illuminate\Container\Container->call(Array)
#5 /vagrant/source/laravel-excel/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(685): Illuminate\Foundation\Application->bootProvider(Object(Maatwebsite\Excel\ExcelServiceProvider))
#6 [internal function]: Illuminate\Foundation\Application->Illuminate\Foundation\{closure}(Object(Maatwebsite\Excel\ExcelServiceProvider), 19)
#7 /vagrant/source/laravel-excel/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(686): array_walk(Array, Object(Closure))
#8 /vagrant/source/laravel-excel/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/BootProviders.php(15): Illuminate\Foundation\Application->boot()
#9 /vagrant/source/laravel-excel/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(181): Illuminate\Foundation\Bootstrap\BootProviders->bootstrap(Object(Illuminate\Foundation\Application))
#10 /vagrant/source/laravel-excel/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(195): Illuminate\Foundation\Application->bootstrapWith(Array)
#11 /vagrant/source/laravel-excel/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(92): Illuminate\Foundation\Console\Kernel->bootstrap()
#12 /vagrant/source/laravel-excel/artisan(36): Illuminate\Foundation\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#13 {main}

php artisan ran sucessfully when I took out the maatwebsite references in config/app.php - so there must be more to do here but I don't know what.

like image 210
mikelovelyuk Avatar asked Oct 19 '22 13:10

mikelovelyuk


1 Answers

Looks like the documentation is listing the wrong version. The 1.x branch is meant for Laravel 4.x. The GitHub page provides a better guide for Laravel 5 users. Try changing the version to 2.* in your composer.json and re-run composer update. Add the correct references back to your app.php you should be able to run php artisan without errors.

The App::make('excel') command should also work after that.

like image 187
Maarten00 Avatar answered Oct 22 '22 02:10

Maarten00