This error usually means that the Intervention Image package is either not installed or not properly autoloaded in your Laravel project.
Here's how to resolve it:
- Install the Intervention Image package via Composer:
composer require intervention/image
- (For Laravel 5.x and below) Register the Service Provider and Facade:
If you are using Laravel 6 or above, Laravel uses package auto-discovery, so you don't need to manually add the service provider or facade.
If you are using Laravel 5.x or below, add the following to your config/app.php:
In the providers array:
Intervention\Image\ImageServiceProvider::class,
In the aliases array:
'Image' => Intervention\Image\Facades\Image::class,
- Clear and cache your config:
php artisan config:clear
php artisan cache:clear
composer dump-autoload
- Check your code for typos:
Make sure you are referencing the correct class name:
Intervention\Image\ImageServiceProvider
Summary:
The error occurs because Laravel can't find the Intervention\Image\ImageServiceProvider class. Installing the package with Composer should resolve the issue.
If you still encounter the error after following these steps, please ensure your composer.json and vendor directory are up to date, and that there are no typos in your service provider registration.