How to install Laravel Dusk in laradock?
Introduction
The local installation of Laravel Dusk has always failed. After checking the documentation, I found that composer require is not all required in laradock, and there are other configurations. Record it below.
Recommended: laravel tutorial
Configuring laradock
1. Switch to the laradock directory and pause docker in the workspace container first -compose sotp workspace
2. Modify WORKSPACE_INSTALL_LARAVEL_INSTALLER and WORKSPACE_INSTALL_DUSK_DEPS in the .env file and change the configuration value to true
3. Rebuild the workspace container docker-compose build workspace
4. After success, start docker-compose up -d workspace
Install Laravel Dusk
1. Enter docker-compose exec workspace bash in the workspace container, and switch Go to the project directory
2. Use composer require --dev laravel/dusk to install Laravel Dusk
3. Execute php artisan dusk:install
4. In tests/DuskTestCase In the .php file, modify the driver method and add the --no-sandbox parameter, as follows
protected function driver() { $options = (new ChromeOptions)->addArguments([ '—disable-gpu', '—headless', '—window-size=1920,1080', '—no-sandbox',// 添加这行 ]); return RemoteWebDriver::create( 'http://localhost:9515', DesiredCapabilities::chrome()->setCapability( ChromeOptions::CAPABILITY, $options ) ); }
1. Add a configuration file, cp .env .env.dusk.local, and change APP_URL to http:// localhost:8000
2. Execute php artisan serve ---quiet &
3. Finally, you can use Laravel Dusk to test php artisan dusk
Conclusion
In fact, there are many aliases in the workspace, but for ease of understanding, the original commands are used.
The above is the detailed content of How to install Laravel Dusk in laradock. For more information, please follow other related articles on the PHP Chinese website!