DEV Community

Cover image for Laravel Sail on Windows
robencom
robencom

Posted on

27

Laravel Sail on Windows

I wanted to write my own detailed walkthrough on how to setup Laravel Sail on a Windows machine.

0- Install Windows Terminal from the Microsoft Store.

1- Check if Virtualization Technology is enabled in your BIOS:
UEFI BIOS (Advanced > CPU Configuration > SVM Mode or Virtualization Technology..

2- enable WSL with this command (via terminal or command prompt with Admin privileges):
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart

3- enable VM with this command (via terminal or command prompt with Admin privileges):
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart

4- Download the Linux kernel update package:
Download WSL2 Linux kernel update package for x64 machines

5- Set WSL2 as your default version (via terminal or command prompt with Admin privileges):
wsl --set-default-version 2

6- Instal Ubuntu 20.04.4 LTS (or whichever Ubuntu you desire) from the Microsoft Store and follow instructions

7- Run the command (via terminal or command prompt with Admin privileges) wsl --list --verbose to verify your installation.

8- Now, download and Install Docker Desktop

9- Open Docker Desktop:

  • in the General tab, click on the gear icon and make sure "Use wsl2 based engine" is checked.
  • in the Resources tab, check your ubuntu Integration and click Apply

10- Open Windows Terminal and cd ~ (to go to the home dir) then type this command to install a fresh Laravel project:
curl -s https://laravel.build/test-project | bash
Obviously, change "test-project" to whatever the name of the project that you desire.

11- To find the files of this project, just open your File Explorer and type: \\wsl$ then you can go to Ubuntu-20.04\home\YOUR_USERNAME\test-project

12- now in the terminal, cd to the new project (cd test-project) and type this command to start sail:
./vendor/bin/sail up
(this will take time for fresh installation)

13- to make an alias, in the terminal :
nano ~/.bashrc
then at the end of the file write:
alias sail='bash vendor/bin/sail'
then apply the change . ~/.bashrc

14- now we can stop it with sail down and turn it on with sail up, we can also pause it with CTRL+C, or as detached mode : sail up -d

15- If using PHPStorm: click File > Open > then type \wsl$\Ubuntu-20.04\ and look for your project

16- IMPORTANT: to shut down the VM, type in terminal:
wsl --shutdown
This will make sure that the VM is not taking memory when you are not using it!

17- As for the database, you can run sail artisan migrate to run the migrations.

18- To connect to the database through MySQL Workbench (or any other database IDE): connecting your SQL Management Software using localhost with the default username: sail and password: password.

DONEEEEEEEEEEEEEEEEEEEEEEEE!!!

So the daily routine after this would be:

        - open terminal
        - type wsl
        - cd ~ then go to the project dir
        - sail up -d
        - then open PHPStorm
Enter fullscreen mode Exit fullscreen mode

For more info, this was the reference I used: REF

Heroku

This site is built on Heroku

Join the ranks of developers at Salesforce, Airbase, DEV, and more who deploy their mission critical applications on Heroku. Sign up today and launch your first app!

Get Started

Top comments (1)

Collapse
 
mostafasharafi profile image
Mostafa

Great Job ! i prefer using Ubuntu as my main OS, but for someone else , i need to have a perspective about using Laravel Sail in windows using Docker Desktop and WSL .

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay