ReflectionException in Container.php Class image does not exist for intervention
Asked Answered
T

2

8

I tried to save an image which comes form POST request using laravel. but it gives me the following error.

ReflectionException in Container.php line 741: Class image does not exist

I did the following things : enabling the fileinfo extension in php.ini file and composer dumpautoload but nothing is work I followed the guide line here I am using laravel 5.1

my code is as bellow

public function saveImage(){

    Image::make(Input::file('files')->getRealPath())
        ->resize(870, null, true, false)
        ->save('foo.jpg');

}
Thirtythree answered 6/2, 2016 at 13:48 Comment(2)
Did you update your config/app.php for the $providers and $aliases ?Cucurbit
yes I put the aliasesThirtythree
M
25

Did you include the class, in the top of the document?

use Intervention\Image\ImageManagerStatic as Image;
Marna answered 6/2, 2016 at 13:59 Comment(1)
Oh, it's the problem, intellij automatically use the use Intervention\Image\Facades\Image; when I change it to use Intervention\Image\ImageManagerStatic as Image;, then work fine thank youThirtythree
E
0

I managed to fix that by adding the following to the config/app.php

 'providers' => [
        Intervention\Image\ImageServiceProvider::class
    ],
    
    'aliases' => [
        'Image'     => Intervention\Image\Facades\Image::class
    ],
Extraversion answered 7/11, 2022 at 7:8 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.