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

pakuize's avatar

Class not found

Hi

So I seem to have an error somewhere and hope someone can help me out here. or point me in the right direction as I seems to have hit a wall and unable to find my error.

So I installed a package : intervention/image I added the service provider in config/app.php as so: 'Intervention\Image\ImageServiceProvider',

I also added the Facade: 'Image' => 'Intervention\Image\Facades\Image',

however I am receiving the following error : Class 'Intervention\Image\ImageServiceProvider' not found

At first I thought I would run composer dump-autoload but as that did not work I tried to run php artisan clear-compiled with no success either I also manually checked that the class exists and it does.

Anyone have any idea please let me know.

0 likes
16 replies
mstnorris's avatar

Can you paste the error as you get it, as it will tell us where the error has occurred.

Also, try running the following again:

composer dump-autoload -o and then composer update just to be sure.

pakuize's avatar

The full error is this:

FatalErrorException in ProviderRepository.php line 150:
Class 'Intervention\Image\ImageServiceProvider' not found
in ProviderRepository.php line 150
at FatalErrorException->__construct() in HandleExceptions.php line 131
at HandleExceptions->fatalExceptionFromError() in HandleExceptions.php line 116
at HandleExceptions->handleShutdown() in HandleExceptions.php line 0
at ProviderRepository->createProvider() in ProviderRepository.php line 115
at ProviderRepository->compileManifest() in ProviderRepository.php line 59
at ProviderRepository->load() in Application.php line 468
at Application->registerConfiguredProviders() in RegisterProviders.php line 15
at RegisterProviders->bootstrap() in Application.php line 183
at Application->bootstrapWith() in Kernel.php line 199
at Kernel->bootstrap() in Kernel.php line 110
at Kernel->sendRequestThroughRouter() in Kernel.php line 84
at Kernel->handle() in index.php line 53
at {main}() in index.php line 0

the composer dump-autoload -o did unfortunately not do the trick.

1 like
mstnorris's avatar
  1. Remove the line 'Intervention\Image\ImageServiceProvider' from your **config/app.phpfile, and runcomposer update` again.

  2. Once it has done that, add the line back.

  3. Run composer dump-autoload -o

1 like
pakuize's avatar

tried several times now still with the exact same error which seems really odd as the line no longer exist and the package have been removed, and it is not being called from my app anywhere.

mstnorris's avatar

@pakuize delete the vendor/compiled.php and the storage/framework/compiled.php run composer update again. This should trigger php artisan clear-compiled and php artisan optimise to be run too, if it doesn't, run those as well.

sitesense's avatar

Try it like this:

\Image::make('foo.jpg')->resize(300, 200);
mstnorris's avatar

@pakuize run php artisan --version to check explicitly and exactly what version you're using.

pakuize's avatar

that would be Laravel Framework version 5.0.32

pakuize's avatar

well this is a little wierd I just fired up my labtop and pulled my project down on it, and there is no problem on that machine at all it's running as expected.

Could this be something to do with timestamps as my normal machine here has some trouble keeping the time correct it's changing every now and then due to a almost dead cmos battery

sitesense's avatar

Not sure about the time thing but glad you got it working anyway :)

mstnorris's avatar

@pakuize I doubt it was the time thing. More likely your project ran composer install thus creating the vendor directory :)

pakuize's avatar

So far it does seem like it is the time, as I fixed the clock on the pc, then the project worked as expected. Then a little later here the clock switched back again and the project again came with the same error. Now just fixed the time again and now the project is working again.

This might just be an issue for windows users I do not know, it's not often I am at a windows pc anymore.

However with of you thank you both @sitesense and @mstnorris for your input and very fast replys, this is why I love coming onto this forum help full people everywhere

pankajadhikary's avatar

Try it like this: In composer.json file "require": {

    "intervention/image": "^2.4",
    "doctrine/orm": "^2.5"
},

after that composer update , cache clear

Please or to participate in this conversation.