Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Texas's avatar

intervention/image

I installed intervention/image package and I keep getting the "Class Image" not found error.. I did composer update, composer dump-autoload, composer dump-autoload -o.... nothing happens.. the error is still there... What can I do ?

I need this package to resize some images... is there any other way of resizing pictures in laravel 5? because if this package doesn't work, I need to fix the pictures problem anyway...

Thanks

0 likes
13 replies
martinbean's avatar

@Texas Have you imported the class (i.e. with its full namespace) at the top of your PHP file? It won’t work if you try and use just Image, you have to use it’s fully-qualified name (i.e. use Intervention\Image\Image;). If you’re trying to use the façade then again, you’ll need to import it: use Image;.

Texas's avatar

I used this use Intervention\Image before and didn't work. I wrote use Intervention\Image\Image; and I got Class 'Intervention\Image\Image' not found

dotemup's avatar

I had an error where I was migrating to a new install where I declared it in the app.config before actually installing it with composer and it would throw errors like that. Make sure you composer install it then import the service providers.

Then like @martinbean said you need to declare the namespace where you want to use it use Image;

martinbean's avatar

@Texas Can you show some code? It’s difficult to diagnose “class not found” errors without context.

Texas's avatar

This is the the code... the last line is the one with the error

$extension = \Input::file('Photo')->getClientOriginalExtension(); // getting image extension
        $fileName = md5($UserName).'.'.$extension; 
        $ufile=\Input::file('Photo');
        $ufile->move($destinationPath, $fileName);
        $img = Image::make($destinationPath.$fileName)->resize(320, 240)->save($destinationPath.$fileName);```
Texas's avatar

@dotemup i have this in app.php: Intervention\Image\ImageServiceProvider::class, --in providers 'Image' => Intervention\Image\Facades\Image::class, ---in aliases

martinbean's avatar

@Texas Try prefixing your use of Image with a backslash, like you have done with the Input façade.

Texas's avatar

Still getting an error: Class 'Intervention\Image\ImageServiceProvider' not found

Maybe the package wasn't installed correctly ... do you know the steps of properly intalling a package ?

martinbean's avatar

@Texas

  1. Remove the façade and service provider lines from your config/app.php file.
  2. Run composer require "intervention/image=~2.0".
  3. If you get any errors saying Image can not be found, comment them out in your code.
  4. Re-add façade and service provider definitions in your app.php config file.
1 like
dotemup's avatar

Like I said I had the same issue, you need to remove the lines in your config/app.php that reference it before actually installing it in composer.

So remove those lines from your config, then run the composer install intervention

Texas's avatar

I did what you both told me and I'm getting this error: FatalErrorException in ProviderRepository.php line 146: Class 'Intervention\Image\ImageServiceProvider' not found in ProviderRepository.php line 146 at FatalErrorException->__construct() in HandleExceptions.php line 133 at HandleExceptions->fatalExceptionFromError() in HandleExceptions.php line 118 at HandleExceptions->handleShutdown() in HandleExceptions.php line 0 at ProviderRepository->createProvider() in ProviderRepository.php line 114 at ProviderRepository->compileManifest() in ProviderRepository.php line 60 at ProviderRepository->load() in Application.php line 507 at Application->registerConfiguredProviders() in RegisterProviders.php line 17 at RegisterProviders->bootstrap() in Application.php line 203 at Application->bootstrapWith() in Kernel.php line 223 at Kernel->bootstrap() in Kernel.php line 118 at Kernel->sendRequestThroughRouter() in Kernel.php line 88 at Kernel->handle() in index.php line 54 in server.php line 21 at {main}() in server.php line 0

Texas's avatar

For those who will encounter the same problem, Adding 'Intervention\\Image\\' => array($vendorDir . '/intervention/image/src/Intervention/Image'), in autoload_psr4.php solved the problem

Please or to participate in this conversation.