5

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
Maytham Fahmi
  • 31,138
  • 14
  • 118
  • 137
Somentus
  • 95
  • 2
  • 11

3 Answers3

2

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.

0

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.

Alexey Mezenin
  • 158,981
  • 26
  • 290
  • 279
  • Did it with `composer dumpauto`, terminal said "Generating autoload files", after reloading webpage error still exists.. `composer dumpauto -o`, terminal outputs "Generating optimized autoload files", again no effect on the error. – Somentus Aug 12 '16 at 15:59
  • Try to manually delete all `php` files in `bootstrap/cache` directory and run `composer dumpauto` again. – Alexey Mezenin Aug 12 '16 at 16:02
  • Deleted the `php` file in `bootstrap/cache`, error still pops up. – Somentus Aug 12 '16 at 16:05
  • Ok, did you get any errors during package installation? Do you have `\vendor\intervention\image\src\Intervention\Image\ImageServiceProvider.php` file in project directory? – Alexey Mezenin Aug 12 '16 at 16:07
  • No errors during install, but it seems I don have `\vendor\intervention\`. – Somentus Aug 12 '16 at 16:11
  • Ok. Remove facade and service provider from config again and run `composer require intervention/image`. This should install intervention (loot at errors and messages). After that run `composer dumpauto -o` and add service provider and facade to the config again. – Alexey Mezenin Aug 12 '16 at 16:13
  • Terminal after `composer require intervention/image`: `Using version ^2.3 for intervention/image ./composer.json has been updated Loading composer repositories with package information Updating dependencies (including require-dev) Nothing to install or update Generating autoload files` Did the `composer dumpauto -o`, added the lines in `config\app.php`. Still the same error. Files are still missing from `vendor`. – Somentus Aug 12 '16 at 17:19
  • Then you'll need to remove it from `composer.json` and run `composer update` to unistall it first. And install it like I described in my previous comment. – Alexey Mezenin Aug 13 '16 at 05:57
  • DId everything, still no folder in my `vendor` .. Does this mean I screwed up somewhere else? I'm not super great with Linux. I'm doing all of these commands in the `~\.composer\` folder of my VM, not in my laravel folder, is that correct? – Somentus Aug 13 '16 at 12:27
  • You get `Nothing to install or update` again? Are you sure you deleted intervention from `composer.json` and ran `composer update`? If yes, what message(s) did you get (it should tell you intervention package was removed or something like that). Also, try to delete `composer.lock` file. Double check everything again. – Alexey Mezenin Aug 13 '16 at 12:32
  • ` - Removing intervention/image (2.3.7)` is what it said (among with the usual lines) after I edited the `.json` and ran `composer update`. When I ran `composer require intervention/image`, it said ` - Installing intervention/image (2.3.7) Loading from cache intervention/image suggests installing ext-imagick (to use Imagick based image processing.) intervention/image suggests installing intervention/imagecache (Caching extension for the Intervention Image library)` among with the usual stuff. Deleting `composer.lock` and running `composer update` had no effect either. – Somentus Aug 13 '16 at 12:37
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.