Image class not found when using Intervention

Joe W picture Joe W · May 26, 2016 · Viewed 13k times · Source

I have installed Laravel 5.2 and Intervention, this is now in the composer.json file in the project.

"require": {
        "php": ">=5.5.9",
        "laravel/framework": "5.2.*",
        "intervention/image": "^2.3"
    },

After reading tutorials, it mentions an Image.php file that should be in the config folder inside the project once you have installed Intervention. I believe I have installed Intervention correctly but when I try to use the Intervention functions it does not work.

When I try to use this line of code I get this error

$resizedImg = Image::make($path)->resize(200,200);

C:\xampp\htdocs\socialNet\vendor\laravel\framework\src\Illuminate\Container\Container.php line 738:

Class image does not exist

and in the file I am using this function I include this Use statement

use Intervention\Image\Facades\Image as Image;

Answer

Abhishek picture Abhishek · May 26, 2016

In your app.php Add this in your aliases:

'Image' => Intervention\Image\Facades\Image::class,

and in your providers

Intervention\Image\ImageServiceProvider::class,

Don't forget to do php artisan config:cache after this.