Shubhra Sarker
Shubhra Sarker

Reputation: 133

Class 'NunoMaduro\Collision\Adapters\Laravel\CollisionServiceProvider' not found

When trying to install composer in laravel project get this error.

Illuminate\Foundation\ComposerScripts::postAutoloadDump @php artisan package:discover In ProviderRepository.php line 208:

Class 'NunoMaduro\Collision\Adapters\Laravel\CollisionServiceProvider' not
found
Script @php artisan package:discover handling the post-autoload-dump event returned with error code 1

Upvotes: 10

Views: 15981

Answers (10)

Mcload
Mcload

Reputation: 308

This is one of the comments, but this should be the accepted answer as this is what actually solves the problem. the package was already in my 'require' section and not in 'require-dev' yet the error still happened.

deleting bootstrap/cache fixed the issue: rm -f bootstrap/cache/*.php

Upvotes: 1

james
james

Reputation: 26271

This could be a simple solution, although not always the correct one:

Delete the cache files (services.php, packages.php, etc) in <project dir>/bootstrap/cache directory. Refresh the page and it may be fixed. The problem could be that your packages.php and services.php are out of date, and the application is attempting to load packages/services that no longer exist.

Upvotes: 0

kirschkern
kirschkern

Reputation: 1407

In my case, the solution was simple: Delete all files within the bootstrap/cache/ directory.

NOTE: The bootstrap/cache/ directory need to be present, so don't delete it.

Thanks to @8ctopus for pointing in the right direction.

Upvotes: 0

8ctopus
8ctopus

Reputation: 3247

In your case the problem was that after running composer install --no-dev, php artisan package:discover is run automatically.

Whenever php artisan command fails, it tries to use the class NunoMaduro\Collision\Adapters\Laravel\CollisionServiceProvider for error handling which is only installed when laravel development packages are used. As you can see in this composer.json, collision is in the require-dev group.

    "require-dev": {
        "nunomaduro/collision": "^6.1",
    },

The problem can be solved by:

  • moving the dependency to the require section
  • or figuring out what causes the artisan command error.

In my case, it was either outdated php files or permission issues in the bootstrap/cache directory.

Upvotes: 8

manunoly
manunoly

Reputation: 49

  • move nunomaduro/collision: ^2.0 from require-dev to require in composer

If that doesn't solve the problem, try

  • deleting the composer.lock file
  • uploading the project again without this file (it solved it for me)

Upvotes: 4

Hemant Maurya
Hemant Maurya

Reputation: 174

I am using 5.6 version with php version 7.2

Tried these page solutions

but following worked for me

in terminal

  1. composer outdated
  2. composer require nunomaduro/collision:^3.0 --dev

Note: I have no Idea if the first step is must but I wrote that command in terminal, Try using 2nd only, if it works then suggest me to edit please.

Thank you.

I found this solution from Git Hub page Github

Upvotes: 2

azi.mohammadi
azi.mohammadi

Reputation: 47

in php v-8 i get this error " Call to undefined method Dotenv\Repository\RepositoryBuilder::create()" and then in terminall type this "composer outdated" and then i know i should update nunomaduro/collision then in terminal "composer require nunomaduro/collision"

Upvotes: -1

Ethan Borkosky
Ethan Borkosky

Reputation: 1

Inside of your composer.lock ,

Move "nunomaduro/larastan": "^0.3.0", to "require" from "require-dev" .

then run composer install

this worked for me

Upvotes: 0

Tria Bagus
Tria Bagus

Reputation: 1

I have answer in folder boostrap/cache/packages.php , we will succes .So delete package is error.

Class 'NunoMaduro\Collision\Adapters\Laravel\CollisionServiceProvider' not found

Deleting...

So you PHP artisan serve.

Upvotes: -2

Mark Wright
Mark Wright

Reputation: 129

I had this issue when deploying my app to Google App Engine. I found that by moving "nunomaduro/collision": "^2.0" from "require-dev" to "require" in my composer.json fixed this problem.

Upvotes: 12

Related Questions