Openemr:flex add xdebug using Dockerfile

@benmarte ,

I would step back a bit. change the port in launch.json from 9003 to 9000 and do a docker-compose down -v then docker-compose up -d.

Note xdebug.mode is already set to debug in flex, so that should not be needed.

Note that xdebug.discover_client_host will get collect the remote host. So, should not need these additional settings. However, what is your client environment? Are you running browser off a docker instance in your computer, your localhost computer directly, or another computer altogether? After sort this out, there may be good reason to add a client_host setting to allow hard-coding of this if xdebug.discover_client_host will fail in the environment.

Also, I am lazy on testing and just put a breakpoint in interface/globals.php. Then any script including login.php will hit it several times.

Also, ensure you are using most updated flex docker (it has recently had a big update to alpine 3.13) via:

docker pull openemr/openemr:flex

@stephenwaite , @benmarte ,

When we get to instruction set, should consider following changes in launch.json:

  1. Change ${workspaceRoot} to ${workspaceFolder} since the first one is getting deprecated
  2. Remove log value since won’t need when our instruction set works for everybody :slight_smile:
  3. Remove externalConsole value since this is already false by default
1 Like

@brady.millerIf I use port 9000 it does not work, I found out which port xdebug is using by putting a phpinfo() function and saw it is using 9003.

My current setup is using docker development easy and using my browser on my windows PC to test/debug. My windows box does not have PHP installed or anything else I am just doing development using the files in opener mounted as a volume in the docker-compose as it is setup from the main repo.

So all I do is clone the main repo and docker-compose up and work all I needed to debug PHP was do the stuff I mentioned above most of the configs in php.ini for xdebug are for version 2 which is why it was throwing errors in my logs.

I’m just writing down what has/hasn’t worked for me this whole week trying to get a dev environment setup/working properly, I will try to setup the same environment on my Mac to test and on my surface as well to make sure port 900 or 9003 works on all setups and document my findings.

Thanks for the comments/help :slight_smile:

hi @benmarte, if you rebuild as @brady.miller suggested do you see the below after running
cat /etc/php7/php.ini in the openemr docker?

; start xdebug configuration
zend_extension=/usr/lib/php7/modules/xdebug.so
xdebug.output_dir=/tmp
xdebug.start_with_request=trigger
xdebug.mode=debug,profile
xdebug.profiler_output_name=cachegrind.out.%s
xdebug.remote_handler=dbgp
xdebug.client_port=9000
xdebug.discover_client_host=1
xdebug.idekey=PHPSTORM
xdebug.log=/tmp/xdebug.log
; end xdebug configuration

New Default xdebug port is 9003, this along with xdebug.mode is required for step debugging and profiling has different requirements

1 Like

thank you @Julie_b, just found this change

@benmarte , @Julie_b , @stephenwaite ,

Related PR is here that should address all the issues and make xdebug configuration a bit more flexible:

2 Likes

Awesome, glad to help :slight_smile:

1 Like

Interesting I’m having issues in OSX getting xdebug to work with the same changes I made in windows :thinking:

I think I’m going to wait until you push your changes to the docker image @brady.miller so I can properly test in both environments and provide feedback.

@brady.millerok figured out the problem on OSX I needed to install the xdebug extension and enable it, once I did that and the 2 line changes I did on windows it works flawlessly :raised_hands:

I will check again once you update the flex image, thanks.

1 Like

@benmarte, just updated the flex docker on dockerhub :slight_smile:

Note that should always need a xdebug browser extension for xdebug to work since it is set to xdebug.start_with_request=trigger

1 Like

@brady.miller just FYI I pulled the latest flex and it works as long as we specify
XDEBUG_CLIENT_HOST: host.docker.internal in the docker-compose.yml so docs need to be updated.

@benmarte ,

Will try to add that setting to all the docker-compose.yml scripts. Then this means that if the https://xdebug.org/docs/all_settings#discover_client_host

setting fails, then it will use this client_host setting (notably, host.docker.internal only works in linux for newest versions of docker; guessing it will just be ignored in prior versions of docker, hopefully it won’t throw errors in that situation, but if it does, we will soon find out :slight_smile: )

@benmarte ,
Just brought in this change, so should now work for you out of box :slight_smile:

2 Likes