Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

biniyam20's avatar

Class 'Laravel\Dusk\DuskServiceProvider' not found

I'm deploying on my Forge server and I'm running into these errors. First error.

In DuskServiceProvider.php line 43:
                                           
  It is unsafe to run Dusk in production. 

So then I added --no-dev to my existing script in Forge.

composer install --no-dev --no-interaction --prefer-dist --optimize-autoloader

Now I get the following error even though I have added Laravel\Dusk\DuskServiceProvider::class, to my providers array in config/app. In addition I have read Taylor's post https://medium.com/@taylorotwell/package-auto-discovery-in-laravel-5-5-ea9e3ab20518 saying to add "laravel/dusk" to don't discover in composer.json

  Class 'Laravel\Dusk\DuskServiceProvider' not found  

Any guidance would be much appreciated as this application and error are in production.

Also, is there a best practice to "rollback" a deployment on forge? I want to be able to revert a breaking change if Forge runs into an error.

0 likes
1 reply
biniyam20's avatar

Update: So my "solution" is to remove Laravel\Dusk\DuskServiceProvider::class, from the providers array in config/app so the production deployment goes well, however then I cannot run dusk tests locally. It feels like I am in a never ending loop.

Please or to participate in this conversation.