Asked  7 Months ago    Answers:  5   Viewed   49 times

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:

'InterventionImageImageServiceProvider'

'Image' => 'InterventionImageFacadesImage'

When I open my website, i get this error:

Class 'InterventionImageImageServiceProvider' not found

Why is that and what should I do now?

 Answers

36

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.

InterventionImageImageServiceProvider::class

Step 4:

Next add this to the $aliases array.

'Image' => InterventionImageFacadesImage::class

Step 5:

If there is an error;

Class 'InterventionImageImageServiceProvider' not found

try

$ composer update
Wednesday, March 31, 2021
 
Raef
answered 7 Months ago
75

If you upgraded to 8 from a previous version you are probably missing the autoload directive for the DatabaseFactories namespace in composer.json:

"autoload": {
    "psr-4": {
        "App\": "app/",
        "Database\Factories\": "database/factories/",
        "Database\Seeders\": "database/seeders/"
    }
},

You can also remove the classmap part, since it is no longer needed.

Run composer dump after making these changes.

Laravel 8.x Docs - Upgrade Guide - Database - Seeder and Factory Namespace

Wednesday, March 31, 2021
 
Giovanni
answered 7 Months ago
56

In Laravel 5 you can inject a new instance of TeamleaderCompany into the methods you need it available in.

use TeamleaderCompany;

class RegisterController extends Controller {

    public function index($id = null, Company $company)
    {
        dd($company);
    }

    public function register(Company $company)
    {
        dd($company);
    }
}

For Laravel <5 dependency inject into the constructor.

use TeamleaderCompany;

class RegisterController extends Controller {

    protected $company;

    public function __construct(Company $company)
    {
        $this->company = $company;
    }

    public function index($id = null)
    {
        dd($this->company);
    }

    public function register()
    {
        dd($this->company);
    }
}

Dependency injection is better than manual invocation as you can easily pass a mock object to this controller during testing. If you're not testing, maybe someone else will be in the future, be kind. :-)

Wednesday, March 31, 2021
 
rblarsen
answered 7 Months ago
38

I believe I know the reason now.

The new class MemberInvitationSeeder wasn't in the autoloaded classes in the composer.json file.

It wasn't there because I added that class manually.

Now, going forward, if I add such classes again, what should I use in order for my class to automatically to the autoloader?

Saturday, May 29, 2021
 
Exoon
answered 5 Months ago
99

The PHP GD library uses a resource object to represent images. You can use imagecopyresampled or imagecopyresized to resize the image.

If it has been resized, use the new resized image object for future operations, otherwise use the original resource object.

Saturday, May 29, 2021
 
jedwards
answered 5 Months ago
Only authorized users can answer the question. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :