How to fix Class 'Meneses\LaravelMpdf\LaravelMpdfServiceProvider' not found in laravel

Avatar
C

Callum Davies

Senior Backend Engineer••
12094Views
5mRead
0Reactions

Hello everyone, in this post, I will share how to fix recent PDF errors in your Laravel 5,6,7,8, 9 & 10 projects.

Understanding the Error:

The error message "Class 'Meneses\LaravelMpdf\LaravelMpdfServiceProvider' not found" typically occurs when Laravel is unable to locate the service provider for the Laravel MPDF package. This error commonly arises due to misconfigurations or incomplete installations.

If you face this error, you should follow the below instructions.

Step-1: Delete composer.json

Delete the composer.json file from the project. After deleting the composer.json file, you need to install the latest pdf package

Step 2: Verify Composer Installation:

Install the latest version of mPDF. Run below command-

composer require mpdf/mpdf

After running this command, you need to update the composer.

If your Laravel project is below 5.5, you need to manually add providers and aliases:

Step 3: Service Provider Registration:

'providers' => [
Mccarlosen\LaravelMpdf\LaravelMpdfServiceProvider::class,
],
.
.
.
.

'aliases'=>[
'PDF' => Mccarlosen\LaravelMpdf\Facades\LaravelMpdf::class,
],

Step 4: Updating the composer

composer update

I hope you will fix your issue if you follow these instructions.

Thank you for your time.

Connect with KoderSolution 🚀

Master modern software engineering, scalable architectures, and advanced backend systems.

What's your setup?How does your production stack handle background jobs? Are you using Redis with Horizon, or cloud queues like AWS SQS?
Callum Davies
C
Written by•Senior Backend Engineer

Callum Davies

PHP & Laravel practitioner since v5.4. Big believer in thin controllers, explicit return types, and boring modular architecture that doesn't page you on weekends.

React to this article

Recommended Articles

View all articles