Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

PHP

Shane McC
Shane McC
3,005 Points

Intervention Image Error Message

I'm trying to figure out how to install Intervention Image. I keep getting the error message Class 'Intervention\Image\ImageServiceProvider' not found

http://laravel.io/bin/jQkJ6 (Better markup)

  1. Installed Intervention/Image by cding over into the correct file (command below)
C:\wamp\bin\php\php5.5.12>composer require intervention/image
Using version ~2.0 for intervention/image
./composer.json has been created
Loading composer repositories with package information
Updating dependencies (including require-dev)
  - Installing intervention/image (2.0.16)
    Downloading: 100% intervention/image suggests installing ext-imagick (to use Imagick based image p
rocessing.)
intervention/image suggests installing intervention/imagecache (Caching extensio
n for the Intervention Image library)
Writing lock file
Generating autoload files
  1. I then followed the below Intervention/Image Laravel 4 installation guidelines http://image.intervention.io/getting_started/installation#laravel

  2. I then got this error message "Class 'Intervention\Image\ImageServiceProvider' not found"

  3. I then ran a composer dump-autoload command on the root of my app (root-> C:\wamp\www\laravel\register) Within 10 seconds I got "Generating autoload files"

  4. I'm still getting the error message "Class 'Intervention\Image\ImageServiceProvider' not found"

  5. I then ran a composer update --no-scripts command on the root of my app (root-> C:\wamp\www\laravel\register). The files were successfully created but I'm still getting the error message.

  6. I then went back to my workbench directory of the verify package (C:\wamp\bin\php\php5.5.12) and ran a composer dump-autoload Within 10 seconds I got "Generating autoload files"

  7. I then went back to the root directory of my app (C:\wamp\www\laravel\register) and ran a php artisan dump-autload command and I got this error message

C:\wamp\www\laravel\register>php artisan dump-autoload
{"error":{"type":"Symfony\\Component\\Debug\\Exception\\FatalErrorException","me
ssage":"Class 'Intervention\\Image\\ImageServiceProvider' not found","file":"C:\
\wamp\\www\\laravel\\register\\vendor\\laravel\\framework\\src\\Illuminate\\Foun
dation\\ProviderRepository.php","line":157}}
  1. So I ran a composer dump-autoload command on the root directory of my app and got the below response. Within 10 seconds I got "Generating autoload files"

My question is, what am I doing wrong? How do I fix this problem?

4 Answers

What version of Laravel are you on?

It looks like you've done something strange around step 1 because it says "composer.json" has been created - it should already exist in a Laravel install.

In your composer.json within the require-dev section can you see intervention/image (2.0.16)?

Then go to (I guess) vendor/Intervention/Image/ImageServiceProvider and see if the correct classes exist.

I've also edited your post - make sure you add spaces around the back ticks :-)

Shane McC
Shane McC
3,005 Points

Tom Cawthorn

Thanks for the help. I figured this out late last night. My problem was that I was doing the steps wrong. I was going in reverse order and it now everything seems to be working correctly. Although if someone asked me to install it again I would prob. still run into the same issues :) but with enough perseverance one could figure it out

Ah cool! Glad to hear it.

Just watch out you haven't installed unwanted composer files etc in you php version directory: C:\wamp\bin\php\php5.5.12> !!

Shane McC
Shane McC
3,005 Points

@Tom Cawthorn how would I check that? what would I look for....

Maybe I've misread your code, but in step 1, you said something like cd'ing over to the correct location, and your command line looked like this:

C:\wamp\bin\php\php5.5.12>composer require intervention/image

This looks to me like you required intervention/image inside the directory of your php version instead of your laravel application.. But maybe it's just the formatting of your command line / copy and pasting.

This would explain why a composer.json file was created in step 1 - unless this was intentional. Was it intentional?

Shane McC
Shane McC
3,005 Points

I don't think I did that. I posted a few images of my C:\wamp\bin\php\php5.5.12

http://tinyurl.com/lfqt38x

http://tinyurl.com/kb22yoa

Thanks

I can see two composer files in this image http://tinyurl.com/kb22yoa. It's quite an important folder and my knowledge of this directory isn't massive. I bet if you open that composer.json file you'll find intervention/image (2.0.16)!

It can be sketchy deleting stuff from this directory if you don't know what you're doing. If I don't know, and you don't know, and everything still works it can probably be left to sit there :-p

Shane McC
Shane McC
3,005 Points

@Tom Cawtom, you and I agree. Everything is currently working fine. I'm not going to touch anything. Thanks again for your help