Somentus
Somentus

Reputation: 95

Laravel 5.2: Class 'Intervention\Image\ImageServiceProvider' not found

I am trying to integrate Intervention Image into my project. I have followed the guide, used a shitton of other tutorials and no matter what I do, I keep getting the same error:

Class 'Intervention\Image\ImageServiceProvider' not found

It is included in my composer.json:

{
    "require": {
        "laravel/envoy": "~1.0",
        "laravel/installer": "^1.3",
        "intervention/image": "^2.3"
    }
}

I have installed the php-gd thingy, I included

Intervention\Image\ImageServiceProvider::class

and

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

in my config\app.php, but I keep getting the annoying error message. Maybe it's worth mentioning that I am on a Linux Mint OS and that I am using the Homestead Virtual Machine. Yes, I included the thingies in the Homestead version of Composer, not on my main PC's composer. When using

PHP artisan --version

, it returns:

Laravel Framework version 5.2.43

I ran composer update on the Virtual Machine, didn't solve the problem. I tried removing the lines from app.php, running composer update, adding the lines again and running composer update, didn't work.

Does it matter where I have the inclusions in config\app.php? Right now, the alias is in the list and the provider is under Package Service Providers.

Here is the full error message:

Whoops, looks like something went wrong.

1/1
FatalThrowableError in ProviderRepository.php line 146:
Class 'Intervention\Image\ImageServiceProvider' not found
in ProviderRepository.php line 146
at ProviderRepository->createProvider('Intervention\Image\ImageServiceProvider') in ProviderRepository.php line 114
at ProviderRepository->compileManifest(array('Illuminate\Auth\AuthServiceProvider', 'Illuminate\Broadcasting\BroadcastServiceProvider', 'Illuminate\Bus\BusServiceProvider', 'Illuminate\Cache\CacheServiceProvider', 'Illuminate\Foundation\Providers\ConsoleSupportServiceProvider', 'Illuminate\Cookie\CookieServiceProvider', 'Illuminate\Database\DatabaseServiceProvider', 'Illuminate\Encryption\EncryptionServiceProvider', 'Illuminate\Filesystem\FilesystemServiceProvider', 'Illuminate\Foundation\Providers\FoundationServiceProvider', 'Illuminate\Hashing\HashServiceProvider', 'Illuminate\Mail\MailServiceProvider', 'Illuminate\Pagination\PaginationServiceProvider', 'Illuminate\Pipeline\PipelineServiceProvider', 'Illuminate\Queue\QueueServiceProvider', 'Illuminate\Redis\RedisServiceProvider', 'Illuminate\Auth\Passwords\PasswordResetServiceProvider', 'Illuminate\Session\SessionServiceProvider', 'Illuminate\Translation\TranslationServiceProvider', 'Illuminate\Validation\ValidationServiceProvider', 'Illuminate\View\ViewServiceProvider', 'Intervention\Image\ImageServiceProvider', 'App\Providers\AppServiceProvider', 'App\Providers\AuthServiceProvider', 'App\Providers\EventServiceProvider', 'App\Providers\RouteServiceProvider')) in ProviderRepository.php line 60
at ProviderRepository->load(array('Illuminate\Auth\AuthServiceProvider', 'Illuminate\Broadcasting\BroadcastServiceProvider', 'Illuminate\Bus\BusServiceProvider', 'Illuminate\Cache\CacheServiceProvider', 'Illuminate\Foundation\Providers\ConsoleSupportServiceProvider', 'Illuminate\Cookie\CookieServiceProvider', 'Illuminate\Database\DatabaseServiceProvider', 'Illuminate\Encryption\EncryptionServiceProvider', 'Illuminate\Filesystem\FilesystemServiceProvider', 'Illuminate\Foundation\Providers\FoundationServiceProvider', 'Illuminate\Hashing\HashServiceProvider', 'Illuminate\Mail\MailServiceProvider', 'Illuminate\Pagination\PaginationServiceProvider', 'Illuminate\Pipeline\PipelineServiceProvider', 'Illuminate\Queue\QueueServiceProvider', 'Illuminate\Redis\RedisServiceProvider', 'Illuminate\Auth\Passwords\PasswordResetServiceProvider', 'Illuminate\Session\SessionServiceProvider', 'Illuminate\Translation\TranslationServiceProvider', 'Illuminate\Validation\ValidationServiceProvider', 'Illuminate\View\ViewServiceProvider', 'Intervention\Image\ImageServiceProvider', 'App\Providers\AppServiceProvider', 'App\Providers\AuthServiceProvider', 'App\Providers\EventServiceProvider', 'App\Providers\RouteServiceProvider')) in Application.php line 530
at Application->registerConfiguredProviders() in RegisterProviders.php line 17
at RegisterProviders->bootstrap(object(Application)) in Application.php line 203
at Application->bootstrapWith(array('Illuminate\Foundation\Bootstrap\DetectEnvironment', 'Illuminate\Foundation\Bootstrap\LoadConfiguration', 'Illuminate\Foundation\Bootstrap\ConfigureLogging', 'Illuminate\Foundation\Bootstrap\HandleExceptions', 'Illuminate\Foundation\Bootstrap\RegisterFacades', 'Illuminate\Foundation\Bootstrap\RegisterProviders', 'Illuminate\Foundation\Bootstrap\BootProviders')) in Kernel.php line 232
at Kernel->bootstrap() in Kernel.php line 127
at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 99
at Kernel->handle(object(Request)) in index.php line 53

Upvotes: 5

Views: 9171

Answers (5)

Mostafijur Rahman
Mostafijur Rahman

Reputation: 1

I have faced the same class not found problem on Laravel 9.52 version and solved it by following this link and downgrading to V2 is not a good idea.

https://image.intervention.io/v3/introduction/frameworks

Upvotes: 0

user13493837
user13493837

Reputation:

After many hours, various attempts and following all of the advice that keeps getting repeated on this one: I solved it by downgrading to v2. Then it worked on the first try.

Upvotes: 0

Make sure you followed the installation guide carefully.

You need to first run:

composer require intervention/image

and you should modify config.app.php after you already install this package (so after run composer require) and not before.

Upvotes: 0

user3366705
user3366705

Reputation: 35

I had the same issue, it turns out i wasn't running this command $ php composer.phar require intervention/image on the root of my project. I did ran it on the root of my project and everything was fine.

E.g Itses-MacBook-Pro:testproject bigtank$ composer require intervention/image

run it like this and it would work.

Cheers.

Upvotes: 2

Alexey Mezenin
Alexey Mezenin

Reputation: 163978

Remove facade and service provider from config/app.php, then run composer dumpauto (if it will not help, run composer dumpauto -o). After that add facade and service provider back to config/app.php.

Upvotes: 0

Related Questions