Laravel 4
"maatwebsite/excel": "~1.3"
Laravel 5
"maatwebsite/excel": "~2.0"
"require-dev": {
"fzaninotto/faker": "~1.4",
"mockery/mockery": "0.9.*",
"phpunit/phpunit": "~4.0",
"phpspec/phpspec": "~2.1",
"maatwebsite/excel": "~2.0.0"
},
添加完后执行 composer update
After updating composer, add the ServiceProvider to the providers array in app/config/app.php
'Maatwebsite\Excel\ExcelServiceProvider',
You can use the facade for shorter code. Add this to your aliasses:
'Excel' => 'Maatwebsite\Excel\Facades\Excel',
The class is binded to the ioC as excel
$excel = App::make('excel');
Laravel 4
Laravel Excel includes several config settings for import-, export-, view- and CSV-specific settings. Use the artisan publish command to publish the config file to your project.
php artisan config:publish maatwebsite/excel
The config files can now be found at app/config/packages/maatwebsite/excel
Laravel 5
To publish the config settings in Laravel 5 use:
php artisan vendor:publish
This will add an excel.php
config file to your config folder.
详细用法请参考官网 http://www.maatwebsite.nl/laravel-excel/docs/getting-started