laravel-5intervention

Call to undefined method Intervention\Image\Facades\Image::make()


I upgraded from Laravel 4.2 to Laraveld5.3 with intervention/image : "^2.3",

 if (Input::hasFile('logo')) {

        $path = public_path()."/assets/admin/layout/img/";
        File::makeDirectory($path, $mode = 0777, true, true);

        $image      = Input::file('logo');
        $extension  = $image->getClientOriginalExtension();
        $filename   = "logo.$extension";
        $filename_big   = "logo-big.$extension";

        Image::make($image->getRealPath())->save($path.$filename);
        Image::make($image->getRealPath())->save($path.$filename_big);

        $data['logo']   =   $filename;

    }

The result Is, got the error below:

Call to undefined method Intervention\Image\Facades\Image::make()

Solution

  • I experienced the same issue in my Laravel 5.4 project. I stumble on this link

    that help resolve the issue. This was the fix that was provided

    In config/app change 'aliases' for Image from

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

    To

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

    Then in your controller header add

    use Image;