Windows10上のHomesteadで、Laravel dusk環境を作る方法(Failed to connect to localhost対策含む)

This time, I have summarized how to create Laravel dusk environment with Homestead on Windows 10.

In addition, building a Homestead environment on Windows 10 is summarized in the following article.
How to build Laravel Homestead on Windows 10 Summary

OK.Let’s go.

It is assumed that the homestead environment and Laravel have been installed.

(1) Install laravel duskand initialize

■Laravel 5.8 Laravel Dusk (Official)
https://laravel.com/docs/5.8/dusk

composer require --dev laravel/dusk
php artisan dusk:install

Preparation is complete only with the above two lines.

php artisan dusk

So, I should be able to do a browser test, but when I run it I get the following error:

Failed to connect to localhost port 9515: Connection refused

Apparently, in Homestead environment built on Windows 10, Chrome driver seems strange.

(参考)■Homestead上でlaravelのdusk使おうとしたらFailed to connect to localhost port 9515: Connection refusedって言われる(Japanese only)
https://twinbird-htn.hatenablog.com/entry/2019/05/10/002248

I referred to the above site.

First, launch vagrant and enter virtual machine

vagrant up
vagrant ssh

Next, install chrome-driver

sudo apt install libnss3

sudo wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add -
sudo sh -c 'echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list'
sudo apt-get update
sudo apt-get install google-chrome-stable

Now you can run dusk.

In addition, in using this method

vagrant destroy --force

It seems to be necessary to do it again when deleting a virtual machine and then vagrant up.

laravel

Posted by dog-ears