Texas
Texas

Reputation: 453

Errors with intervention\image

I need to resize pictures in my laravel 5 project and I need the intervention/image package. So I ran composer update, than composer require intervention/image and I get this error:

FatalErrorException in ProviderRepository.php line 146:
Class 'Intervention\Image\ImageServiceProvider' not found

...which is very strange because I can see the Intervention package in my vendor folder At the top of the file I have use Intervention\Image\Image;

I've done this 3 or 4 times today and I still have the problem. How can I make this package work ?

Upvotes: 2

Views: 1201

Answers (2)

Zakaria Acharki
Zakaria Acharki

Reputation: 67505

Adding 'Intervention\\Image\\' => array($vendorDir . '/intervention/image/src/Intervention/Image'), in autoload_psr4.php solved the problem.

Take a look at Class 'Intervention\Image\Image Service Provider' not found [solved].

Upvotes: 1

davsp
davsp

Reputation: 2179

Add the following to your config/app.php:

'providers' array-

'Intervention\Image\ImageServiceProvider',

and on 'aliases' further down

'Image' => 'Intervention\Image\Facades\Image'

In your controller you can then put the following:

use Intervention\Image\Facades\Image;

You can then make calls to Image:: methods, for example:

 Image::make($request->file('image'))->resize(300, null, function ($constraint) {
            $constraint->aspectRatio();

Upvotes: 0

Related Questions