Skip to content

Sceleton to debug php scripts in docker container

Notifications You must be signed in to change notification settings

mopkob1/phpdebug

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Container to debug php-scripts на php v.8x

XDebug 3 only started working out of the box with PhpStorm version 2020.3

Reference article - Configure Xdebug

The list of changes from XDebug 2 to 3 are available here for reference - Upgrade Guide

Configuring PhpStorm

Go to PhpStorm -> Settings -> Languages & Frameworks -> PHP -> Servers

  1. Click "+"
  2. Name ddebug (Same as serverName under PHP_IDE_CONFIG environment variable)
  3. Host _
  4. Default 80
  5. Debugger Xdebug
  6. Check the checkbox next to "Use path mappings"
  7. Modify the absolute path on the server to /var/www/html

Running the CLI Command

  1. Add breakpoints file
  2. In PhpStorm click the icon to "Start Listening for PHP Debug connections"
  3. Run in the docker file:
 docker exec debug php index.php
  1. Run without nginx:
SCRIPT_NAME=/index.php \
SCRIPT_FILENAME=/var/www/html/index.php \
REQUEST_METHOD=GET \
cgi-fcgi -bind -connect 127.0.0.1:9035
# Install cgi-fcgi:
sudo apt update && sudo apt install libfcgi0ldbl

Troubleshooting

  1. Check firewall or selinux if on linux
  2. The configuration host.docker.internal only became available under Mac and Windows with Docker version 20.04

Add to docker-compose follow lines:

extra_hosts:
  - "host.docker.internal:host-gateway"

Change attrs:

mkdir -p /tmp/xdebug
chmod -R 777 /tmp/xdebug

About

Sceleton to debug php scripts in docker container

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published