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.
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.