How to add PHPExcel library in laravel?

I want to create a new module in laravel that includes the PHPExcel library. where to put the library. how to access it.

I placed the PHPExcel library in the location below

laravel\project\application\libraries\PHPEXCEL 

this gives me a PHP error Fatal error: class "PHPExcel" not found.

+6
source share
2 answers

You can use the PHPExcel Composer package . Just add "phpoffice/phpexcel": "dev-master" to your composer.json and enter composer update . Thus, the library will be “installed” and you can use it as usual (for example, $objPHPExcel = new PHPExcel(); ). No need to manually turn on, etc.

Update may 2016

Instead of editing composer.json use the 'official' command:

composer require phpoffice/phpexcel

+9
source

Below is an example of using the PHPEXCEL library with laravel 5

1: - Install the "phpoffice" package in Laravel 5. Below is the link for packages

2: - Add "phpexcel / phpexcel": "dev-master" to your composer.json. Example: - "required": {"phpexcel / phpexcel": "dev-master"}

3: - Then do the “composer update”.

4: - Open the file "/vendor/composer/autoload_namespaces.php". Insert the bottom line into the file.

// Enable PHPEXCEL library with Laravel 5
'PHPExcel' => array ($ vendorDir. '/ Phpoffice / phpexcel / Classes'),

5: - Now you can use the PHPEXCEL library in your controllers or middleware or library. Use PHPExcel use PHPExcel_IOFactory;

For more information, you can access the link https://github.com/pantlavanya/export-to-excel-using-phpoffice-phpexcel-in-laravel-5 .

+1
source

All Articles