sfneal/view-export

Export Views from Laravel applications to PDF or Excel files
3,529
Install
composer require sfneal/view-export
Latest Version:2.10.2
PHP:>=7.4
License:MIT
Last Updated:Jul 8, 2021
Links: GitHub  ·  Packagist
Maintainer: sfneal

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.

Related Packages

sfneal/redis-helpers

Redis helper functions for improved Redis cache transactions with PHP applicatio...

145,583 0
sfneal/caching

Traits & interfaces for utilizing cache mechanisms to store frequently retrieved...

117,701 1
sfneal/queueables

Abstraction layers for creating Jobs & Queueable's in Laravel applications

109,753 0
sfneal/models

Eloquent Model wrapper with extended functionality

98,220 1
sfneal/laravel-helpers

Helper functions for Laravel applications

146,004 1