Laravel has an awesome tool for browser testing called Laravel Dusk. And we have its Test Generator within our QuickAdminPanel, but a few customers encountered this error, so will try to explain how to avoid it and what it actually means.

This is how the error looks.

And it happens only in case your .env file has this value:


Basically, when you try to deploy to production server, it should not contain Laravel Dusk package. Here’s an excerpt from official docs:

If you are manually registering Dusk’s service provider, you should never register it in your production environment, as doing so could lead to arbitrary users being able to authenticate with your application.

In other words, if there’s Dusk running on your live server, then there’s browser available for nasty hackers to abuse it.

So there are two options here.

Option 1. Maybe you have ‘production’ by mistake?

Maybe you misconfigured your environment and you’re working on your local machine?
Then your .env file should contain APP_ENV value of ‘local’, ‘staging’, ‘testing’ or whatever, but not ‘production’.

Also, keep in mind that there’s a difference between .env and .env.examplehere’s how to use them properly.

Finally, maybe you haven’t even set up .env file? Laravel will still run, but will take environment values from config files. So let’s look at config/app.php and see its default value.

'env' => env('APP_ENV', 'production'),

In other words, if you haven’t set up .env file, your environment is ‘production’ by default. You can change it here to ‘local’ if you don’t want to mess around with .env files for some reason.

Option 2. Production composer should have –no-dev

Here’s how our typical composer.json looks like:

  "require": {
    "php": ">=7.0.0",
    "fideloper/proxy": "~3.3",
    "laravel/framework": "5.5.*",
    "laravel/tinker": "~1.0",
    "laravelcollective/html": "^5.5",
    "intervention/image": "^2.4",
    "doctrine/dbal": "^2.5"
  "require-dev": {
    "filp/whoops": "~2.0",
    "fzaninotto/faker": "~1.4",
    "mockery/mockery": "0.9.*",
    "phpunit/phpunit": "~5.7",
    "laravel/dusk": "^2.0"

See the last line – laravel/dusk package, which is included in require-dev section. It means that those package are needed only for local/dev/testing environments, here’s a Stackoverflow topic about it.

Now, if you run composer install without any flags, it will still install ALL the packages, both from “require” and “require-dev”.

So in production environment you should run this:

composer install --no-dev

The flag “–no-dev” will tell composer to not install anything from “require-dev”, therefore Dusk won’t be installed, and you will avoid the error above.

You can read more about Laravel Dusk here.

And here’s a demo-video how our Test Generator works.