image icon indicating copy to clipboard operation
image copied to clipboard

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

Open nickdelja opened this issue 12 years ago • 39 comments

I am unable to make images. I get the following message:

Symfony \ Component \ Debug \ Exception \ FatalErrorException Call to undefined method Intervention\Image\Facades\Image::make() open: /Users/Sites/gcfs/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php

I am running Intervention\Image 1.6.2

nickdelja avatar Apr 16 '14 06:04 nickdelja

A code example would help

djekl avatar Apr 16 '14 07:04 djekl

$image = Image::make('https://avatars2.githubusercontent.com/u/1119714?s=140');

I was reading somewhere that I might have to rename the facade? Is that correct?

nickdelja avatar Apr 16 '14 07:04 nickdelja

Are you using a custom namespace? Or is it simply within say a route?

Route::get('foo', function() {
    $image = Image::make('http://placehold.it/500x500/000/e8117f');
    return Response::make($image->encode('jpg'), 200, ['Content-Type' => 'image/jpeg']);
});

pop that in your routes file and give it a go

djekl avatar Apr 16 '14 07:04 djekl

It is in a controller. I tried added the route you have specified for debugging, but get the same message. Here is the message from the error log:

[2014-04-16 07:33:50] local.ERROR: exception 'Symfony\Component\Debug\Exception\FatalErrorException' with message 'Call to undefined method Intervention\Image\Facades\Image::make()' in /Users/ndelja/Sites/gcfs/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php:208 Stack trace: #0 [internal function]: Illuminate\Exception\Handler->handleShutdown() #1 {main} [] [] screen shot 2014-04-16 at 12 33 51 am

nickdelja avatar Apr 16 '14 07:04 nickdelja

Strange, just to confirm you have definitely done the full install? http://image.intervention.io/getting_started/laravel

Laravel 4 Integration

Intervention Image has optional support for Laravel 4 and comes with a _Service Provider and Facades_ for easy integration. After you have installed the Image class correctly, just follow the instructions.

Open your Laravel config file config/app.php and add the following lines.

In the $providers array add the service providers for this package.

'Intervention\Image\ImageServiceProvider'

Add the facade of this package to the $aliases array.

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

djekl avatar Apr 16 '14 07:04 djekl

That is correct. I have the config configured correctly. Everything was working in the application about 7 months. I just got back to redeveloping and ran composer update. Here are the requires in the config:

    "laravel/framework": "4.1.*",
    "facebook/php-sdk": "dev-master",
    "intervention/image": "1.*",
    "ikimea/browser": "dev-master"

nickdelja avatar Apr 16 '14 07:04 nickdelja

You could try renaming the Facade but I have never needed to. Also if you have just update everything today you may also want to have a look at the Laravel upgrade guide http://laravel.com/docs/upgrade

Other than that, I don't know. Can only suggest trying a fresh laravel install then require the lib and add my foo route. If that doesn't work then it could be something on the server maybe??

djekl avatar Apr 16 '14 07:04 djekl

I got same error, this is my solve method: Open your Laravel config file config/app.php and add the following lines. In the $providers array add the service providers for this package. 'Intervention\Image\ImageServiceProvider' Add the facade of this package to the $aliases array. 'Image' => 'Intervention\Image\Facades\Image' Now the Image Class will be auto-loaded by Laravel. Reference http://image.intervention.io/getting_started/laravel

xuri avatar May 03 '14 08:05 xuri

@Luxurioust I have exactly what you have in my app.php file. My image was just uploading just fine before I ran composer update. Ever since I ran it, it won't work... I'm getting the same error as the original poster.. and still can't fix it.

// Open image, resize, and save
$img = Image::make( $image );

$img->resize($this->largeThumbWith, $this->largeThumbHeight, true)->save($this->directory . $img->filename . '_thumb.' . $img->extension);

Where image is simply the path to the image (it exists as well.. already checked that).

IntellectProductions avatar May 20 '14 19:05 IntellectProductions

I think it may have something to do with also have a model called 'Image'. I have a model called 'Image and I am getting this error. I changed the facade to:

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

in the aliases array and it works fine. Is there a better way to handle this conflict?

rodleviton avatar May 22 '14 10:05 rodleviton

I had this problem after a composer upgrade also. had everything working before.

with @rodleviton suggestion it did work so I started wondering if it was because of the import on the top of the controller and in fact it was.

so back to 'Image' => 'Intervention\Image\Facades\Image' and no use Intervention\Image\Image; on the top (import)

mikeziri avatar Jun 05 '14 22:06 mikeziri

Broke for me as well, and I'm not integrating with laravel. I believe this change caused my problem: https://github.com/Intervention/image/commit/9bb6b213c26e3b61d3563c0974a44e2bef1b86dd#diff-f1c7a6ff10b1242aedacf53acceccdebL134

For now I'm jumping back to the prior commit until things are resolved.

stratease avatar Jun 09 '14 22:06 stratease

Sorry for not responding earlier. The problem that I was having was do to not updating config/app.php in dev, staging and production. Just a user error.

nickdelja avatar Jun 09 '14 23:06 nickdelja

I had the same problem, and the same solution...i just forgot to update the app.php file under the local enviroment

cabrerabywaters-zz avatar Jun 12 '14 23:06 cabrerabywaters-zz

Still having the problem :/ Unfortunately changing the alias name to 'Img' (and any other like 'Imaadfadsfdasfaf' :P) doesn't work for me.

php composer.phar show -i

laravel/framework v4.2.6 The Laravel Framework. intervention/image 2.0.5 Image handling and manipulation library with support for Laravel 4 integration

What's wrong? I'm using also other libraries (ex: https://github.com/barryvdh/laravel-debugbar ), but just the Image alias doesnt work.

ghost avatar Jul 08 '14 13:07 ghost

Hint for the library developers:

when I change a return format in \Intervention\Image\Facades\Image.php from

return 'image'

to

return new \Intervention\Image\Image;

it start "working" - meaning that the exception ("call to undefined method....") isnt throwing. But next error appear

all to a member function executeCommand() on a non-object

in __call() function

ghost avatar Jul 09 '14 05:07 ghost

The problem I had was I only many the changes to the production config and not the development config.

On Jul 8, 2014, at 22:35, Szymon Bluma [email protected] wrote:

Hint for the library developers:

when I change a return format in \Intervention\Image\Facades\Image.php from

return 'image' to

return new \Intervention\Image\Image; it start "working" - meaning that the exception ("call to undefined method....") isnt throwing. But next error appear

all to a member function executeCommand() on a non-object

in __call() function

— Reply to this email directly or view it on GitHub.

nickdelja avatar Jul 09 '14 05:07 nickdelja

Hmmmm... my issue - fixed. I removed the vendor directory and install/update everything once again via composer. Now works :)

ghost avatar Jul 11 '14 09:07 ghost

I'm still having same problem with Laravel

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

I'm using version 2.*. Looking at the Image class in the vendor file. That method make() is not there. However, it's found in ImageManager. I compared this with previous version 1.5. I saw that the make() is actually a method in Image Class.

My question is that i'm referencing the wrong class?

stanwarri avatar Jul 18 '14 20:07 stanwarri

@stanwarri

This has changed in version 2 as mentioned in the update notes

You have to call make from ImageManager or ImageManagerStatic. Laravel does this automatically via the Facade/ServiceProvider. If you're not using Laravel, check out this example.

olivervogel avatar Jul 18 '14 21:07 olivervogel