Laravel Snappy is a PHP package for Snappy; which allow you to create PDF or image file from a URL or a HTML page. To use Laravel Snappy with Laragon, you need a specific setup for it to work.
At the time of writing, Laravel 8 is the latest version. For this tutorial, I’m using Laragon 4.0.16 with PHP v7.4.14, and Apache 2.4. Without further a due, let start this tutorial.
In order for Laravel Snappy to work, you need to install wkhtmltopdf. Go to wkhtmltopdf and download the installer for your Windows. Install wkhtmltopdf using the installer afterward.
Install Laravel Snappy package to your Laravel project using composer.
composer require barryvdh/laravel-snappy
Publish Laravel Snappy configuration file using artisan command.
php artisan vendor:publish --provider="Barryvdh\Snappy\ServiceProvider"
You can check the config file and put customize it accordingly.
Add new variables for WKHTML_PDF_BINARY and WKHTML_IMAGE_BINARY in your .env file. The value for these variables should be map to your wkhtmltopdf exe file location. For example:
That’s all. Now you are ready to use Laravel Snappy in Laragon to develop further your Laravel project.