Laravel invoice can be easily generated using dompdf package. Making invoice is not that much tough. To make invoice in laravel you will have to follow some rules and guidelines. We will have to install composer package, make blade file , create route and so on. This article will give you clear idea how to create invoice pdf in laravel. For making this article complete we will use barryvdh/laravel-dompdf.
For your kind information this article is valid for laravel 8, laravel 9, laravel 10, laravel 11 as well as newer versions. So let's start.
Install Laravel 11 Project
Install barryvdh/laravel-dompdf composer package
Create Route
Create InvoiceController
Add Blade File
Install Laravel 11 Project
composer create-project --prefer-dist laravel/laravel laravel11-pdf
cd laravel11-pdf
Install barryvdh/laravel-dompdf Composer Package
To install barryvdh/laravel-dompdf package we will have to run below command in terminal
composer require barryvdh/laravel-dompdf
Create Necessary Route
To make pdf invoice file we will have to define route in web.php to forward request in method > controller
use App\Http\Controllers\InvoiceController;
use Illuminate\Support\Facades\Route;
Route::get('/download-pdf-invoice', [InvoiceController::class, 'generatePdfInvoice']);