I have Laravel Sail installed in WSL, and I'm trying to debug the application using Xdebug. This only works if I enter the WSL IP address directly into the browser (http://172.17.170.44:8000). If I enter http://localhost:8000 (which I need), the page only loads, but it doesn't connect to PhpStorm - see screen
My configuration:
20-xdebug.ini
[XDebug]
zend_extension = xdebug.so
xdebug.mode = debug
xdebug.start_with_request = yes
xdebug.discover_client_host = true
xdebug.idekey = PHPSTORM
xdebug.client_host = host.docker.internal
xdebug.client_port = 9003
.env
# Xdebug
SAIL_XDEBUG_MODE=develop,debug,coverage
SAIL_XDEBUG_CONFIG="client_host=laravel.test"
part of compose.yaml
services:
laravel.test:
build:
context: ./vendor/laravel/sail/runtimes/8.4
dockerfile: Dockerfile
args:
WWWGROUP: '${WWWGROUP}'
MYSQL_CLIENT: mariadb-client
image: sail-8.4/app
extra_hosts:
- 'host.docker.internal:host-gateway'
ports:
- '${APP_PORT:-80}:80'
environment:
WWWUSER: '${WWWUSER}'
LARAVEL_SAIL: 1
XDEBUG_MODE: '${SAIL_XDEBUG_MODE:-off}'
XDEBUG_CONFIG: '${SAIL_XDEBUG_CONFIG:-client_host=host.docker.internal}'
IGNITION_LOCAL_SITES_PATH: '${PWD}'
volumes:
- '.:/var/www/html'
- './20-xdebug.ini:/etc/php/8.4/cli/conf.d/20-xdebug.ini'
networks:
- sail
depends_on:
- mariadb
- redis
- mongodb
- elasticsearch
