Laravel Development on Docker
Setting Up Docker
- Install DockerDesktop
- Install WSL2 (Windows only)
- Install WSL2-Ubuntu
- Docker -> Setting -> Resources -> WSL Integration -> set "Ubuntu" on
- Disable Window's Firewall-Apps
Start Up A Docker-Compose
- Intall Laravel under WSL2 (type
wsl
to enter):
bash
curl -s "https://laravel.build/example-app" | bash
curl -s "https://laravel.build/example-app" | bash
- Start up a docker-compose via Laravel-Sail (under WSL2):
bash
cd example-app
./vendor/bin/sail up
cd example-app
./vendor/bin/sail up
Xdebug
- Set the appropriate mode(s) before starting Sail:
text
SAIL_XDEBUG_MODE=develop,debug
SAIL_XDEBUG_MODE=develop,debug
- Config PhpStorm
- Set "Start Listening for PHP Debug Connection" on.
- Set "Break at first line in PHP Script" on.
- Start Sail again, refresh the page
http://localhost
. - A debug request should be caught in PhpStorm now. Great, just map current project's path to the server path (should be
/var/www/html
by default).
Reverse-Proxy (Nginx)
- Install Nginx-Proxy-Manager
- Add a DNS record to the
hosts
file:
text
127.0.0.1 proxy.docker.io
127.0.0.1 proxy.docker.io
- Access http://127.0.0.1:81, set up a proxy: