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
wslto enter):
bash
curl -s "https://laravel.build/example-app" | bashcurl -s "https://laravel.build/example-app" | bash- Start up a docker-compose via Laravel-Sail (under WSL2):
bash
cd example-app
./vendor/bin/sail upcd example-app
./vendor/bin/sail upXdebug
- Set the appropriate mode(s) before starting Sail:
text
SAIL_XDEBUG_MODE=develop,debugSAIL_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/htmlby default).
Reverse-Proxy (Nginx)
- Install Nginx-Proxy-Manager
- Add a DNS record to the
hostsfile:
text
127.0.0.1 proxy.docker.io127.0.0.1 proxy.docker.io- Access http://127.0.0.1:81, set up a proxy: