i want to create new module in laravel which include PHPExcel library. where to put library. how to access it.
i have put the PHPExcel library at below location
laravel\project\application\libraries\PHPEXCEL
it give me error PHP Fatal error: Class 'PHPExcel' not found.
1:- Add "phpoffice/phpexcel": "dev-master" to your composer. json. 2:- execute "composer update" on terminal. 3:- Open the file "/vendor/composer/autoload_namespaces.
PHPExcel is a PHP library providing an ability to work (read/create/edit) spreadsheet files (formats: . xls, . xlsx, CSV, . ods, and some others). Official PHPExcel library page on GitHub https://github.com/PHPOffice/PHPExcel.
You can use the PHPExcel Composer package. Just add "phpoffice/phpexcel": "dev-master"
to your composer.json
and enter composer update
. This way the library will be "installed" and you can use it as normal (for example $objPHPExcel = new PHPExcel();
) No need for manual includes etc.
Update may 2016
Instead of editing your composer.json
, please use the 'official' command:
composer require phpoffice/phpexcel
Below are the step to use PHPEXCEL Library with laravel 5
1:- Install "phpoffice" Package in Laravel 5. Below is the link for the packages
2:- Add "phpexcel/phpexcel": "dev-master" to your composer.json. Ex:- "require": { "phpexcel/phpexcel": "dev-master" }
3:- Then execute "composer update".
4:- Open the file "/vendor/composer/autoload_namespaces.php". Paste the below line in the file.
// Include PHPEXCEL Library with Laravel 5
'PHPExcel' => array($vendorDir . '/phpoffice/phpexcel/Classes'),
5:- Now you can use PHPEXCEL library in your controllers or middleware or library. use PHPExcel; use PHPExcel_IOFactory;
For more details you can access "https://github.com/pantlavanya/export-to-excel-using-phpoffice-phpexcel-in-laravel-5" link.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With