Home >PHP Framework >Laravel >Detailed explanation of installing Laravel Dusk in laradock

Detailed explanation of installing Laravel Dusk in laradock

藏色散人
藏色散人forward
2020-03-31 08:54:553022browse

Detailed explanation of installing Laravel Dusk in laradock

Introduction

Installing Laravel Dusk locally has always failed. After checking the documentation, I found that laradock is not the only Just need composer require, there are other configurations. Record it below.

Configuring laradock

1. Switch to the laradock directory and pause the workspace container first docker-compose sotp workspace

2. Modify the .env file WORKSPACE_INSTALL_LARAVEL_INSTALLER and WORKSPACE_INSTALL_DUSK_DEPS, 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 to the project directory

2. Use composer require - -dev laravel/dusk Install Laravel Dusk

3. Execute php artisan dusk:install

4. In the tests/DuskTestCase.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, 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 using , for ease of understanding, the original commands are used.

Recommended: laravel tutorial

The above is the detailed content of Detailed explanation of installing Laravel Dusk in laradock. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:segmentfault.com. If there is any infringement, please contact admin@php.cn delete