Laravel has a great tool for browser tests called Laravel Dusk. And we have its test generator in our QuickadminPanel, but some customers have encountered this error, so will try to explain how to avoid it and what it really means.
This is what the error looks like.
And this only happens in case your .G The file has this value:
APP_ENV=production
Basically, when you try to deploy on production server, it should not contain the Laravel Dusk package. Here is an extract from official documents:
If you manually record the twilight service provider, you must never record it in your production environment, as this could lead arbitrary users to be authenticated with your application.
In other words, if there is twilight on your live server, there is a browser available for unpleasant hackers to abuse it.
So there are two options here.
Option 1. Perhaps you have a “production” by mistake?
Maybe you have misplaced your environment and work on your local machine?
Then your .G The file must contain App_env “Local” value, “staging”, “test” or other, but not “production”.
Also keep in mind that there is a difference between .G And .Well. Example – Here’s how to use them correctly.
Finally, maybe you haven’t even installed .G deposit? Laravel will always run, but will take environmental values from the configuration files. So let’s look at Config / App.php and see its default value.
'env' => env('APP_ENV', 'production'),
In other words, if you have not configured .G file, your environment is “production” by default. You can change it here by “local” if you don’t want to play with .G files for any reason.
Option 2. The production composer should have – no div
Here’s how our typical compose It 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. This means that these packages are only necessary for local / dev / test environments, here is a stackoverflow subject on this subject.
Now if you run Composer installation Without any flag, he will always settle ALL The packages, both “require” and “require-def”.
So, in a production environment, you must execute this:
composer install --no-dev
The “–No-DEV” flag will indicate to the composer not to install anything from “require-DEV”, the twilight will therefore not be installed, and you will avoid the error above.
You can find out more about Laravel Dusk here.
And here is a Demo-Video how our test generator works.