Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Intervention Image Laravel 5.1

Tags:

php

laravel

I tried to resize img, I do this step: update composer:

"intervention/image": "dev-master",

next add lines in app/config

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

In my controller:

use Intervention\Image\Image as Img;
Img::make($destination_path . $filename)->resize(200, 200)->save($destination_path . $filename);

and this is error:

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

All In laravel 5.1

like image 673
Jensej Avatar asked Jul 19 '15 13:07

Jensej


3 Answers

Just follow the below Steps:

1) Open composer.json file from your root directory

      "require": {
        "php": ">=5.5.9",
        "laravel/framework": "5.2.*",
        "laravel/socialite": "^2.0",

        // add these lines
        "illuminate/html": "5.*",
        "intervention/image": "dev-master"
    }

2) Now run composer update command to get those packages.

 composer update

3) Open config/app.php file

a) update the providers array with the following line.

     'providers' => [

        // add this line at the bottom  
        Intervention\Image\ImageServiceProvider::class
        ]

b) update the aliases array with the following line.

'aliases' => [
         // add this line at the bottom 
        'Image'     => Intervention\Image\Facades\Image::class
        ],

4) You are done!

See details here: http://www.pranms.com/intervention-image-integration-in-laravel/

like image 86
Mamunur Rashid Avatar answered Nov 02 '22 09:11

Mamunur Rashid


Try:

1) check if you have model in your App (by default) folder named as Image

2)

a) put use Image; to the top of your controller

b) throw this away: use Intervention\Image\Image as Img;

c) just use this: Image::make( not Img:make(

like image 9
M0rtiis Avatar answered Nov 02 '22 10:11

M0rtiis


I had the same problem myself. After a lot of googling, I found this tutorial specific for Laravel 5.1.

Simply change

use Intervention\Image\Image;

to

use Intervention\Image\Facades\Image;
like image 3
miniPax Avatar answered Nov 02 '22 11:11

miniPax