31

I just installed Intervention Image Class following instructions from here: http://image.intervention.io/getting_started/installation

I also added these 2 lines into config/app.php file:

'Intervention\Image\ImageServiceProvider'

'Image' => 'Intervention\Image\Facades\Image'

When I open my website, i get this error:

Class 'Intervention\Image\ImageServiceProvider' not found

Why is that and what should I do now?

Community
  • 1
  • 1
Tomas Turan
  • 1,105
  • 3
  • 16
  • 25

7 Answers7

72

Step 1:

Add "intervention/image": "dev-master" to the “require” section of your composer.json file.

"require": {
    "laravel/framework": "4.1.*",
    "intervention/image": "dev-master"
},

Step 2:

Run CMD;
$ composer install

If you've got this warning:

Warning: The lock file is not up to date with the latest changes in composer.json. You may be getting outdated dependencies. Run update to update them.

do $ composer update and then $ composer install

Step 3:

open the config/app.php file. Add this to the $providers array.

Intervention\Image\ImageServiceProvider::class

Step 4:

Next add this to the $aliases array.

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

Step 5:

If there is an error;

Class 'Intervention\Image\ImageServiceProvider' not found

try

$ composer update
Marc Farshad
  • 46
  • 1
  • 8
Qamar Uzman
  • 882
  • 8
  • 4
17

Try this, It works for me.

use Intervention\Image\Facades\Image as Image;
Morteza Rajabi
  • 2,264
  • 1
  • 20
  • 23
17
composer require intervention/image

solves definitively the problem.

Polarix
  • 329
  • 2
  • 9
  • 1
    The intervention/image release tags are changed and using `dev-master` as version number will fail. This solution solves the problem by using the latest release as version number. – AMIB Dec 16 '18 at 16:40
  • really it worked, thanks – logudotcom Feb 19 '21 at 05:56
3

Try add \ symbol before Image:

\Image::make();

It helped for me on Laravel 5.3 and Intervention 2.3

Gediminas
  • 5,859
  • 6
  • 37
  • 53
3
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"require": {
    "laravel/framework": "4.2.*",
    "intervention/image": "dev-master"
},

add new code "intervention/image": "dev-master" in composer.json, and cmd

$ composer update
3

just write that on the controller

use Image;

config/app.php providers

Intervention\Image\ImageServiceProvider::class,

Alias

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

Turan Zamanlı
  • 3,161
  • 1
  • 13
  • 19
3

In laravel 5.8 you can easily fix that error.

first open config folder app.php file add providers

   Intervention\Image\ImageServiceProvider::class,

then goto aliases and add the

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

open the the if you want to image upload controller add the

  use Image;

providers

           'providers' => [

    /*
     * Laravel Framework Service Providers...
     */
    Illuminate\Auth\AuthServiceProvider::class,
    Illuminate\Broadcasting\BroadcastServiceProvider::class,
    Illuminate\Bus\BusServiceProvider::class,
    Illuminate\Cache\CacheServiceProvider::class,
    Illuminate\Foundation\Providers\ConsoleSupportServiceProvider::class,
    Illuminate\Cookie\CookieServiceProvider::class,
    Illuminate\Database\DatabaseServiceProvider::class,
    Illuminate\Encryption\EncryptionServiceProvider::class,
    Illuminate\Filesystem\FilesystemServiceProvider::class,
    Illuminate\Foundation\Providers\FoundationServiceProvider::class,
    Illuminate\Hashing\HashServiceProvider::class,
    Illuminate\Mail\MailServiceProvider::class,
    Illuminate\Notifications\NotificationServiceProvider::class,
    Illuminate\Pagination\PaginationServiceProvider::class,
    Illuminate\Pipeline\PipelineServiceProvider::class,
    Illuminate\Queue\QueueServiceProvider::class,
    Illuminate\Redis\RedisServiceProvider::class,
    Illuminate\Auth\Passwords\PasswordResetServiceProvider::class,
    Illuminate\Session\SessionServiceProvider::class,
    Illuminate\Translation\TranslationServiceProvider::class,
    Illuminate\Validation\ValidationServiceProvider::class,
    Illuminate\View\ViewServiceProvider::class,
    Intervention\Image\ImageServiceProvider::class,

    /*
     * Package Service Providers...
     */

    /*
     * Application Service Providers...
     */
    App\Providers\AppServiceProvider::class,
    App\Providers\AuthServiceProvider::class,
    // App\Providers\BroadcastServiceProvider::class,
    App\Providers\EventServiceProvider::class,
    App\Providers\RouteServiceProvider::class,

],

aliases

      'aliases' => [

    'App' => Illuminate\Support\Facades\App::class,
    'Arr' => Illuminate\Support\Arr::class,
    'Artisan' => Illuminate\Support\Facades\Artisan::class,
    'Auth' => Illuminate\Support\Facades\Auth::class,
    'Blade' => Illuminate\Support\Facades\Blade::class,
    'Broadcast' => Illuminate\Support\Facades\Broadcast::class,
    'Bus' => Illuminate\Support\Facades\Bus::class,
    'Cache' => Illuminate\Support\Facades\Cache::class,
    'Config' => Illuminate\Support\Facades\Config::class,
    'Cookie' => Illuminate\Support\Facades\Cookie::class,
    'Crypt' => Illuminate\Support\Facades\Crypt::class,
    'DB' => Illuminate\Support\Facades\DB::class,
    'Eloquent' => Illuminate\Database\Eloquent\Model::class,
    'Event' => Illuminate\Support\Facades\Event::class,
    'File' => Illuminate\Support\Facades\File::class,
    'Gate' => Illuminate\Support\Facades\Gate::class,
    'Hash' => Illuminate\Support\Facades\Hash::class,
    'Lang' => Illuminate\Support\Facades\Lang::class,
    'Log' => Illuminate\Support\Facades\Log::class,
    'Mail' => Illuminate\Support\Facades\Mail::class,
    'Notification' => Illuminate\Support\Facades\Notification::class,
    'Password' => Illuminate\Support\Facades\Password::class,
    'Queue' => Illuminate\Support\Facades\Queue::class,
    'Redirect' => Illuminate\Support\Facades\Redirect::class,
    'Redis' => Illuminate\Support\Facades\Redis::class,
    'Request' => Illuminate\Support\Facades\Request::class,
    'Response' => Illuminate\Support\Facades\Response::class,
    'Route' => Illuminate\Support\Facades\Route::class,
    'Schema' => Illuminate\Support\Facades\Schema::class,
    'Session' => Illuminate\Support\Facades\Session::class,
    'Storage' => Illuminate\Support\Facades\Storage::class,
    'Str' => Illuminate\Support\Str::class,
    'URL' => Illuminate\Support\Facades\URL::class,
    'Validator' => Illuminate\Support\Facades\Validator::class,
    'View' => Illuminate\Support\Facades\View::class,
    'Image' => Intervention\Image\Facades\Image::class
],

Controller

  <?php

   namespace App\Http\Controllers;

  namespace App\Http\Controllers;

  use Illuminate\Http\Request;
  use Illuminate\Validation\Rule;
  use DB;
  use App\User;
  use Auth;
  use Image;
  class ImageController extends Controller{
    //code
  }
Dilshan Dilip
  • 494
  • 4
  • 8