Skip to content

Export Views from Laravel applications to PDF or Excel files

License

Notifications You must be signed in to change notification settings

sfneal/view-export

Repository files navigation

View Export

Packagist PHP support Latest Version on Packagist Build Status Quality Score Total Downloads

Export Views from Laravel applications to PDF or Excel files.

Installation

You can install the package via composer:

composer require sfneal/view-export

To modify the view-export config file publish the ServiceProvider.

php artisan vendor:publish --provider="Sfneal\ViewExport\Providers\ViewExportServiceProvider"

Usage

PDFs

Exporting a PDF from a 'view'.

use Sfneal\ViewExport\Pdf\PdfExportService;

// Set the view & upload path
$view = view('your.view', ['example_data' => ['a'=> 2001, 'b' => 3012]]);
$s3Key = 'path/to/save/your/file/example.pdf';

// Initialize an Exporter instance
$exporter = PdfExportService::fromView($view)->handle();

// Upload the PDF
$exporter->upload($s3Key);

// Download in browser
$exporter->download();

// Retrieve the upload path
$path = $exporter->path();

Excel

Exporting an Excel file from a 'view'.

use Sfneal\ViewExport\Excel\ExcelExportService;

// Set the view & upload path
$view = view('your.view', ['example_data' => ['a'=> 2001, 'b' => 3012]]);
$s3Key = 'path/to/save/your/file/example.pdf';

// Initialize an Exporter instance
$exporter = ExcelExportService::fromView($view)->handle();

// Upload the PDF
$exporter->upload($s3Key);

// Download in browser
$exporter->download();

// Retrieve the upload path
$path = $exporter->path();

Testing

composer test

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email stephen.neal14@gmail.com instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

PHP Package Boilerplate

This package was generated using the PHP Package Boilerplate.

About

Export Views from Laravel applications to PDF or Excel files

Resources

License

Stars

Watchers

Forks

Packages

No packages published