Mohamad
Mohamad
خواندن ۴ دقیقه·۳ سال پیش

Phpstorm xdebug sail آموزش

phpstorm xdebug sail
phpstorm xdebug sail


https://medium.com/codex/laravel-8-0-sail-xdebug-phpstorm-5cc900e96da4

Install xdebug

Config PHPSTORM IDE to match xdebug configuration port and server.

Run > Edit configurations...

+ add server > PHP Remote Debug

Config your server name

Run > Web server debug validation

path to create validation script: [public directory of your laravel project]

press validate

change docker-compose.yml file :

# For more information: https://laravel.com/docs/sail version: '3' services: laravel.test: build: extra_hosts: - 'host.docker.internal:host-gateway' context: ./vendor/laravel/sail/runtimes/8.1 dockerfile: Dockerfile args: WWWGROUP: '${WWWGROUP}' XDEBUG: '${XDEBUG}' XDEBUG_PORT: '${XDEBUG_PORT}' image: sail-8.1/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}' PHP_IDE_CONFIG: serverName=Docker volumes: - '.:/var/www/html' networks: - sail depends_on: - mysql - redis mysql: image: 'mysql/mysql-server:8.0' ports: - '${FORWARD_DB_PORT:-3306}:3306' environment: MYSQL_ROOT_PASSWORD: '${DB_PASSWORD}' MYSQL_ROOT_HOST: &quot%&quot MYSQL_DATABASE: '${DB_DATABASE}' MYSQL_USER: '${DB_USERNAME}' MYSQL_PASSWORD: '${DB_PASSWORD}' MYSQL_ALLOW_EMPTY_PASSWORD: 1 volumes: - 'sail-mysql:/var/lib/mysql' networks: - sail healthcheck: test: [&quotCMD&quot, &quotmysqladmin&quot, &quotping&quot, &quot-p${DB_PASSWORD}&quot] retries: 3 timeout: 5s redis: image: 'redis:alpine' ports: - '${FORWARD_REDIS_PORT:-6379}:6379' volumes: - 'sail-redis:/data' networks: - sail healthcheck: test: [&quotCMD&quot, &quotredis-cli&quot, &quotping&quot] retries: 3 timeout: 5s networks: sail: driver: bridge volumes: sail-mysql: driver: local sail-redis: driver: local

add into your php.ini file :

[xdebug] zend_extension=xdebug.so xdebug.profiler_enable=1 xdebug.remote_enable=1 xdebug.remote_handler=dbgp xdebug.remote_mode=req xdebug.remote_host=host.docker.internal xdebug.remote_port=9000 xdebug.remote_autostart=1 xdebug.remote_connect_back=1 xdebug.idekey=PHPSTORM xdebug.mode=debug

Install xdebug browser extension :

Chrome/Firefox/...

After installation you need to config Xdebug extension :

go to xdebug extension options > IDE KEY section > Select PHPSTORM from dropdown list

enable xdebug extension and set breakpoints in your IDE

go and enjoy :)

phpphpstormsailxdebugdocker
Software Engineer | Blogger | Tech Enthusiast
شاید از این پست‌ها خوشتان بیاید