2

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;
2

4 Answers 4

14

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.

Sign up to request clarification or add additional context in comments.

3 Comments

Thanks!! I had the aliases and providers added but I had not run config:cache and the error is now gone
Yes thats the problem. Thats why in development I don't cache the config. Run php artisan config:clear once and you will never run into such problems.
thank you man!!!! you literally saved my life. all i needed to do is php artisan config:clear
1

First, you can use composer :

composer require intervention/image

Then declare it on app.php :

'providers' => [
    // ...
    Intervention\Image\ImageServiceProvider::class,
]

Then, still on app.php on 'aliases' declare it :

'aliases' => [
    // ...
    'Image' => Intervention\Image\Facades\Image::class,
]

Hope it will help

Comments

0

If you've followed the tutorial here: http://image.intervention.io/getting_started/installation#laravel And done everything as described, finally generate all the new classes with the composer command: composer dump-autoload. This will autoload your new facade. After this you can import the Image facade simply by use Image; in the class you wish to use the facade in.

Comments

0

if you have file in modal or controller which filename does not match with class name or name space error in any file then you will not be able to resolve this issue as i have Userold.php was givng me ps-4 error and due to this my any operation was incomplete and i was getting Intervention\Image\ImageServiceProvider::class, first resolve it if anybody have then perform next operation.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.