Openemr:flex add xdebug using Dockerfile

I apologize for my ignorance upfront. I’m fairly new to PHP and am trying to set up a local openemr
environment where I can debug openEMR using PhpStorm and xdebug to learn how it runs. I cloned the openemr/openemr-devops repository locally, modified the Dockerfile to install xdebug, modified the php.ini file with the xdebug directives, created a new image, but get an error at startup - file not found.

Portion of Dockerfile modified - added apk directive to install php7-xdebug

#Install dependencies
RUN apk --no-cache upgrade
RUN apk add --no-cache
apache2 apache2-ssl git php7 php7-tokenizer php7-ctype php7-session php7-apache2
php7-json php7-pdo php7-pdo_mysql php7-curl php7-ldap php7-openssl php7-iconv
php7-xml php7-xsl php7-gd php7-zip php7-soap php7-mbstring php7-zlib
php7-mysqli php7-sockets php7-xmlreader php7-redis perl php7-simplexml php7-xmlwriter php7-
phar php7-fileinfo
php7-sodium php7-calendar
php7-xdebug
mysql-client tar curl imagemagick npm
python3 openssl git libffi-dev py-pip python3-dev build-base openssl-dev dcron
rsync shadow jq

php.ini modifications - the lines I added to end of [PHP] section …

zend_extension=/usr/lib/php7/modules/xdebug.so
xdebug.coverage_enable=0
xdebug.remote_enable=1
xdebug.remote_connect_back=1
xdebug.remote_log=/tmp/xdebug.log
xdebug.remote_autostart=true

I’ll keep looking and experimenting, but if anyone has some recommendations for getting debugging to work with flex I would appreciate it.

Thanks,

Nick

I solved my issue. I just used docker exec to get into the openemr container, followed the xdebug.org wizard recommendations, used docker commit to write out the new image, and now have a openemr container running xdebug. Next step, get it working with PHPStorm.

Well, that was somewhat painful, but I got it working.

add to php.ini file in /etc/php7
;;;;;;;;;;;;;;;;;;;
; Module Settings ;
;;;;;;;;;;;;;;;;;;;
zend_extension=/usr/lib/php7/modules/xdebug.so
xdebug.remote_enable=1
xdebug.remote_autostart=true
xdebug.remote_host=192.168.1.x
xdebug.remote_port=9000
xdebug.remote_handler=dbgp
xdebug.idekey=PHPSTORM

PHPStorm / Settings / Languages & Frameworks / PHP / Debug / DBGp Proxy :
IDE key: PHPSTORM
Host: localhost
Port: 9000

PHPStorm / Settings / Languages & Frameworks / PHP / Debug :
Follow directions in PHPStorm Zero-configuration Debugging Tutorial including install of Xdebug Helper extension for Chrome

PHPStorm / Settings / Languages & Frameworks / PHP / Servers :
Setup localhost server with path mappings

hi @Nicholas_Steblay ,

Did you need to open up port 9000 on the docker-compose.yml? Would be really nice to support this via a docker composer environment setting (so would install everything in real time when start up the docker rather than build it into the Dockerfile) and I plan to make an issue for this.

So, to confirm, from above, need this package:

apk --no-cache upgrade
apk add --no-cache php7-xdebug

then add to php.ini

;;;;;;;;;;;;;;;;;;;
; Module Settings ;
;;;;;;;;;;;;;;;;;;;
zend_extension=/usr/lib/php7/modules/xdebug.so
xdebug.remote_enable=1
xdebug.remote_autostart=true
xdebug.remote_host=192.168.1.x
xdebug.remote_port=9000
xdebug.remote_handler=dbgp
xdebug.idekey=PHPSTORM

Do you still need to make the edits to php.ini from your first post?

Hello @Nicholas_Steblay @brady.miller I am greatly interested in this, Many PHP devs I know mention the wonders of PHPStorm especially with remote debugging via xdebug, I have been frustrated with the complexities of setting that up,plus PHPStorm being a little more heavy than my VScode, Would be very happy to see how it works. I already have an activated version of the PHPStorm IDE .

I have a working xdebug with docker flex up on GitHub if anyone has questions. I think I also had a guide on how to set it up too.

[openemr-devops/docker/openemr/flex-3.10-Xdebug at Xdebug · boxlady/openemr-devops · GitHub]

I need to rebase it with the new changes that were recently made, but you can see how stuff is set up.

I have it setup for both linux and windows now…

2 Likes

Yes, I needed to add port 9000 to the docker-compose.yml

version: ‘3.1’
services:
mysql:
restart: always
image: mariadb:10.4
command: [‘mysqld’,’–character-set-server=utf8’]
ports:
- 3306:3306
volumes:
- databasevolume:/var/lib/mysql
environment:
MYSQL_ROOT_PASSWORD: root
XDEBUG_CONFIG: remote_host=localhost
openemr:
restart: always
# use an image if you’re not changing the build steps:
image: nsteblay/openemr:2.4
# if editing the Dockerfile, clone the devops repo and point to the path:
# build: …/openemr-devops/docker/openemr/flex-edge/
ports:
- 80:80
- 443:443
- 9000:9000
volumes:
- .:/openemr:ro
- .:/var/www/localhost/htdocs/openemr:rw
- publicvolume:/var/www/localhost/htdocs/openemr/public:rw
- sitesvolume:/var/www/localhost/htdocs/openemr/sites/default:rw
- nodemodules:/var/www/localhost/htdocs/openemr/node_modules:rw
- vendordir:/var/www/localhost/htdocs/openemr/vendor:rw
- ccdamodule:/var/www/localhost/htdocs/openemr/ccdaservice:rw
- logvolume:/var/log
environment:
MYSQL_HOST: mysql
MYSQL_ROOT_PASS: root
MYSQL_USER: openemr
MYSQL_PASS: openemr
OE_USER: admin
OE_PASS: pass
EASY_DEV_MODE: “yes”
EASY_DEV_MODE_NEW: “yes”
DEVELOPER_TOOLS: “yes”
ACTIVATE_API: “yes”
GITHUB_COMPOSER_TOKEN: xxx
depends_on:
- mysql
phpmyadmin:
restart: always
image: phpmyadmin/phpmyadmin
ports:
- 8080:80
environment:
PMA_HOSTS: mysql
volumes:
databasevolume: {}
publicvolume: {}
sitesvolume: {}
nodemodules: {}
vendordir: {}
ccdamodule: {}
logvolume: {}

Ya, I was having problems with VS Code. PHPStorm appears to have better capabilities for debugging, especially when using Docker. Julie’s guide looks good for configuring PHPStorm. I used the DBGp proxy on port 9000 and added the IDE key into the php.ini file. I tried doing all the modifications to the docker image using the Dockerfile provided in openemr-devops but wasn’t successful - I’ll try that again. Instead I exec’d into the running flex container and added xdebug as specified by the xdebug.org wizard and wrote out the image using the docker commit command. I’m also using the Xdebug helper extension for Chrome

Brad, I had problems with setting up the flex Dockerfile provided in openemr-devops. I ended up using the docker exec command to start a bash shell in the running flex docker container. I then manually installed xdebug per the recommendations provided by the xdebug.org wizard. It did require a compile using GCC. I then ran the docker commit command to write out the updated image. I tried for hours to get it to work through configuring the Dockerfile but wasn’t successful. I’ll probably try again as some point but am more focused at this time in learning how the PHP code is working for Openemr. If I have time I’ll try again to use the Dockerfile approach.

Hi,
Just added support for xdebug and profiling in the easy development docker environment. Instructions for use are in step 10 of openemr/CONTRIBUTING.md at master · openemr/openemr · GitHub

4 Likes

Thanks for all the hard work setting that up.

1 Like

Did anyone ever get xdebug working with VSCode and Docker or is it only supported via PHPStorm?

hi @benmarte, fixed it with these settings for launch.json in the .vscode directory in project root

and these below

set XDEBUG_IDE_KEY: VSCODE in the docker-compose.yml

{
  // Use IntelliSense to learn about possible attributes.
  // Hover to view descriptions of existing attributes.
  // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
  "version": "0.2.0",
  "configurations": [    
    {
      "name": "Listen for XDebug",
      "type": "php",
      "request": "launch",
      "port": 9000,
      "log": true,
      "externalConsole": false,
      "pathMappings": {
        "/var/www/localhost/htdocs/openemr": "${workspaceRoot}"
      },
      "ignore": [
        "**/vendor/**/*.php"
      ]      
    },
    {
      "name": "Launch currently open script",
      "type": "php",
      "request": "launch",
      "program": "${file}",
      "cwd": "${fileDirname}",
      "port": 9000
    }
  ]
}

I couldn’t help myself (am using Visual Studio for flutter stuff) and was able to get it to work by:

  1. Installing PHP DEBUG

  2. Adding following to the generic launch.json:

            "pathMappings": {
                "/var/www/localhost/htdocs/openemr": "${workspaceFolder}"
            },
           "ignore": [
              "**/vendor/**/*.php"
           ]    

so, launch.json will look like this:

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Listen for XDebug",
            "type": "php",
            "request": "launch",
            "port": 9000,
            "pathMappings": {
                "/var/www/localhost/htdocs/openemr": "${workspaceFolder}"
            },
            "ignore": [
                "**/vendor/**/*.php"
              ]
        },
        {
            "name": "Launch currently open script",
            "type": "php",
            "request": "launch",
            "program": "${file}",
            "cwd": "${fileDirname}",
            "port": 9000
        }
    ]
}

Note there is no need to change the XDEBUG_IDE_KEY, since PHPSTORM (and likely anything there) still triggers the callback. So, in the end, this will actually be easier to configure than PHPStorm :slight_smile:

Also, after my original post, I realized I needed the ignore line in there to avoid bunch of annoying behavior (which i added above). So, it now pretty much looks almost just like @stephenwaite 's script :smile:

1 Like

Am thinking about trying to completely remove the XDEBUG_IDE_KEY setting, since likely not needed and will just cause confusion.

1 Like

Interesting these are the same exact things I have yet when I try to stop at a breakpoint and run the debugger nothing happens :thinking:

Is there a good page I can use to test I just replaced everything on the login.php page and put a breakpoint on this variable I defined but nothing happens.

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <?php 
    $test = "Testing 123...";
    echo $test;
     ?>
</body>
</html>

Debug console seems to be working I guess:

<- launchResponse
Response {
  seq: 0,
  type: 'response',
  request_seq: 2,
  command: 'launch',
  success: true
}

It could be something stupid I’m doing hard to know right now :man_shrugging:

try interface/main/calendar/index.php break point at first require_once, refresh the cal and start stepping

Thanks for that I think the settings are wrong based on what I see in the errror logs:

[Sun Feb 21 14:05:48.516109 2021] [php7:notice] [pid 17] [client 172.19.0.1:59308] Xdebug: [Step Debug] Time-out connecting to debugging client, waited: 200 ms. Tried: host.docker.internal:9003 (through xdebug.client_host/xdebug.client_port) :-(, referer: http://localhost:8300/interface/main/tabs/main.php?token_main=MYTBpRjjcWpfYJJbkmL60E5RNe4RwDyOwsdsFyTZ
[Sun Feb 21 14:05:48.519386 2021] [php7:notice] [pid 250] [client 172.19.0.1:59306] Xdebug: [Step Debug] Time-out connecting to debugging client, waited: 200 ms. Tried: host.docker.internal:9003 (through xdebug.client_host/xdebug.client_port) :-(, referer: http://localhost:8300/interface/main/tabs/main.php?token_main=MYTBpRjjcWpfYJJbkmL60E5RNe4RwDyOwsdsFyTZ
[Sun Feb 21 14:05:48.718137 2021] [php7:notice] [pid 17] [client 172.19.0.1:59308] Xdebug: [Step Debug] Time-out connecting to debugging client, waited: 200 ms. Tried: host.docker.internal:9003 (through xdebug.client_host/xdebug.client_port) :-(, referer: http://localhost:8300/interface/main/tabs/main.php?token_main=MYTBpRjjcWpfYJJbkmL60E5RNe4RwDyOwsdsFyTZ
[Sun Feb 21 14:05:48.721150 2021] [php7:notice] [pid 250] [client 172.19.0.1:59306] Xdebug: [Step Debug] Time-out connecting to debugging client, waited: 200 ms. Tried: host.docker.internal:9003 (through xdebug.client_host/xdebug.client_port) :-(, referer: http://localhost:8300/interface/main/tabs/main.php?token_main=MYTBpRjjcWpfYJJbkmL60E5RNe4RwDyOwsdsFyTZ
[Sun Feb 21 14:05:48.920556 2021] [php7:notice] [pid 17] [client 172.19.0.1:59308] Xdebug: [Step Debug] Time-out connecting to debugging client, waited: 200 ms. Tried: host.docker.internal:9003 (through xdebug.client_host/xdebug.client_port) :-(, referer: http://localhost:8300/interface/main/tabs/main.php?token_main=MYTBpRjjcWpfYJJbkmL60E5RNe4RwDyOwsdsFyTZ
[Sun Feb 21 14:05:51.131311 2021] [php7:notice] [pid 17] [client 172.19.0.1:59308] Xdebug: [Step Debug] Time-out connecting to debugging client, waited: 200 ms. Tried: host.docker.internal:9003 (through xdebug.client_host/xdebug.client_port) :-(, referer: http://localhost:8300/interface/main/messages/messages.php?form_active=1
[Sun Feb 21 14:07:04.752509 2021] [ssl:warn] [pid 36] AH01906: 172.19.0.6:443:0 server certificate is a CA certificate (BasicConstraints: CA == TRUE !?)
[Sun Feb 21 14:07:04.752519 2021] [ssl:warn] [pid 36] AH01909: 172.19.0.6:443:0 server certificate does NOT include an ID which matches the server name
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 172.19.0.6. Set the 'ServerName' directive globally to suppress this message
Xdebug: [Config] The setting 'xdebug.profiler_enable' has been renamed, see the upgrading guide at https://xdebug.org/docs/upgrade_guide#changed-xdebug.profiler_enable (See: https://xdebug.org/docs/errors#CFG-C-CHANGED)
Xdebug: [Config] The setting 'xdebug.profiler_enable_trigger' has been renamed, see the upgrading guide at https://xdebug.org/docs/upgrade_guide#changed-xdebug.profiler_enable_trigger (See: https://xdebug.org/docs/errors#CFG-C-CHANGED)
Xdebug: [Config] The setting 'xdebug.profiler_output_dir' has been renamed, see the upgrading guide at https://xdebug.org/docs/upgrade_guide#changed-xdebug.profiler_output_dir (See: https://xdebug.org/docs/errors#CFG-C-CHANGED)
Xdebug: [Config] The setting 'xdebug.remote_connect_back' has been renamed, see the upgrading guide at https://xdebug.org/docs/upgrade_guide#changed-xdebug.remote_connect_back (See: https://xdebug.org/docs/errors#CFG-C-CHANGED)
Xdebug: [Config] The setting 'xdebug.remote_enable' has been renamed, see the upgrading guide at https://xdebug.org/docs/upgrade_guide#changed-xdebug.remote_enable (See: https://xdebug.org/docs/errors#CFG-C-CHANGED)
Xdebug: [Config] The setting 'xdebug.remote_log' has been renamed, see the upgrading guide at https://xdebug.org/docs/upgrade_guide#changed-xdebug.remote_log (See: https://xdebug.org/docs/errors#CFG-C-CHANGED)
Xdebug: [Config] The setting 'xdebug.remote_port' has been renamed, see the upgrading guide at https://xdebug.org/docs/upgrade_guide#changed-xdebug.remote_port (See: https://xdebug.org/docs/errors#CFG-C-CHANGED)
[Sun Feb 21 14:07:04.763706 2021] [ssl:warn] [pid 36] AH01906: 172.19.0.6:443:0 server certificate is a CA certificate (BasicConstraints: CA == TRUE !?)
[Sun Feb 21 14:07:04.763714 2021] [ssl:warn] [pid 36] AH01909: 172.19.0.6:443:0 server certificate does NOT include an ID which matches the server name
[Sun Feb 21 14:07:04.765057 2021] [mpm_prefork:notice] [pid 36] AH00163: Apache/2.4.46 (Unix) OpenSSL/1.1.1i configured -- resuming normal operations 
[Sun Feb 21 14:07:04.765071 2021] [core:notice] [pid 36] AH00094: Command line: '/usr/sbin/httpd -D FOREGROUND'
[Sun Feb 21 14:19:21.231687 2021] [php7:notice] [pid 47] [client 172.19.0.1:59484] PHP Warning:  Division by zero in /var/www/localhost/htdocs/openemr/interface/login/login.php on line 11
[Sun Feb 21 14:19:21.231707 2021] [php7:notice] [pid 47] [client 172.19.0.1:59484] PHP Stack trace:
[Sun Feb 21 14:19:21.231711 2021] [php7:notice] [pid 47] [client 172.19.0.1:59484] PHP   1. {main}() /var/www/localhost/htdocs/openemr/interface/login/login.php:0
[Sun Feb 21 14:21:43.250158 2021] [php7:notice] [pid 40] [client 172.19.0.1:59492] PHP Warning:  Division by zero in /var/www/localhost/htdocs/openemr/interface/login/login.php on line 11
[Sun Feb 21 14:21:43.250178 2021] [php7:notice] [pid 40] [client 172.19.0.1:59492] PHP Stack trace:
[Sun Feb 21 14:21:43.250182 2021] [php7:notice] [pid 40] [client 172.19.0.1:59492] PHP   1. {main}() /var/www/localhost/htdocs/openemr/interface/login/login.php:0
[Sun Feb 21 14:21:45.002453 2021] [php7:notice] [pid 40] [client 172.19.0.1:59492] PHP Warning:  Division by zero in /var/www/localhost/htdocs/openemr/interface/login/login.php on line 11
[Sun Feb 21 14:21:45.002470 2021] [php7:notice] [pid 40] [client 172.19.0.1:59492] PHP Stack trace:
[Sun Feb 21 14:21:45.002474 2021] [php7:notice] [pid 40] [client 172.19.0.1:59492] PHP   1. {main}() /var/www/localhost/htdocs/openemr/interface/login/login.php:0
[Sun Feb 21 14:21:45.219398 2021] [php7:notice] [pid 40] [client 172.19.0.1:59492] PHP Warning:  Division by zero in /var/www/localhost/htdocs/openemr/interface/login/login.php on line 11
[Sun Feb 21 14:21:45.219414 2021] [php7:notice] [pid 40] [client 172.19.0.1:59492] PHP Stack trace:
[Sun Feb 21 14:21:45.219418 2021] [php7:notice] [pid 40] [client 172.19.0.1:59492] PHP   1. {main}() /var/www/localhost/htdocs/openemr/interface/login/login.php:0
[Sun Feb 21 14:21:56.839051 2021] [php7:notice] [pid 42] [client 172.19.0.1:59494] PHP Warning:  Division by zero in /var/www/localhost/htdocs/openemr/interface/login/login.php on line 11
[Sun Feb 21 14:21:56.839069 2021] [php7:notice] [pid 42] [client 172.19.0.1:59494] PHP Stack trace:
[Sun Feb 21 14:21:56.839072 2021] [php7:notice] [pid 42] [client 172.19.0.1:59494] PHP   1. {main}() /var/www/localhost/htdocs/openemr/interface/login/login.php:0
[Sun Feb 21 14:21:57.524428 2021] [php7:notice] [pid 42] [client 172.19.0.1:59494] PHP Warning:  Division by zero in /var/www/localhost/htdocs/openemr/interface/login/login.php on line 11
[Sun Feb 21 14:21:57.524444 2021] [php7:notice] [pid 42] [client 172.19.0.1:59494] PHP Stack trace:
[Sun Feb 21 14:21:57.524448 2021] [php7:notice] [pid 42] [client 172.19.0.1:59494] PHP   1. {main}() /var/www/localhost/htdocs/openemr/interface/login/login.php:0
[Sun Feb 21 14:22:21.372740 2021] [php7:notice] [pid 44] [client 172.19.0.1:59498] PHP Warning:  Division by zero in /var/www/localhost/htdocs/openemr/interface/login/login.php on line 11
[Sun Feb 21 14:22:21.372759 2021] [php7:notice] [pid 44] [client 172.19.0.1:59498] PHP Stack trace:
[Sun Feb 21 14:22:21.372763 2021] [php7:notice] [pid 44] [client 172.19.0.1:59498] PHP   1. {main}() /var/www/localhost/htdocs/openemr/interface/login/login.php:0
[Sun Feb 21 14:25:09.224623 2021] [php7:notice] [pid 37] [client 172.19.0.1:59508] PHP Warning:  Division by zero in /var/www/localhost/htdocs/openemr/interface/login/login.php on line 12
[Sun Feb 21 14:25:09.224640 2021] [php7:notice] [pid 37] [client 172.19.0.1:59508] PHP Stack trace:
[Sun Feb 21 14:25:09.224644 2021] [php7:notice] [pid 37] [client 172.19.0.1:59508] PHP   1. {main}() /var/www/localhost/htdocs/openemr/interface/login/login.php:0
[Sun Feb 21 14:25:47.893950 2021] [php7:notice] [pid 45] [client 172.19.0.1:59510] PHP Warning:  Division by zero in /var/www/localhost/htdocs/openemr/interface/login/login.php on line 12
[Sun Feb 21 14:25:47.893967 2021] [php7:notice] [pid 45] [client 172.19.0.1:59510] PHP Stack trace:
[Sun Feb 21 14:25:47.893971 2021] [php7:notice] [pid 45] [client 172.19.0.1:59510] PHP   1. {main}() /var/www/localhost/htdocs/openemr/interface/login/login.php:0
[Sun Feb 21 14:26:52.060586 2021] [php7:notice] [pid 46] [client 172.19.0.1:59520] PHP Warning:  Division by zero in /var/www/localhost/htdocs/openemr/interface/login/login.php on line 12
[Sun Feb 21 14:26:52.060613 2021] [php7:notice] [pid 46] [client 172.19.0.1:59520] PHP Stack trace:
[Sun Feb 21 14:26:52.060619 2021] [php7:notice] [pid 46] [client 172.19.0.1:59520] PHP   1. {main}() /var/www/localhost/htdocs/openemr/interface/login/login.php:0

I purposely tried dividing by zero to make it crash but vscode is definitely not working with xdebug.

I think something needs to be changed in xdebug.ini or php.ini will provide more details as I figure it out, thanks.

I updated the php.ini xdebug config with the following:

zend_extension=/usr/lib/php7/modules/xdebug.so
xdebug.remote_handler=dbgp
xdebug.client_port=9000
xdebug.discover_client_host=1
xdebug.client_host=host.docker.internal
xdebug.idekey=VSCODE
xdebug.log=/tmp/xdebug.log
xdebug.mode=debug
xdebug.start_with_request=trigger
xdebug.output_dir=/tmp
xdebug.profiler_output_name=cachegrind.out.%s

No more xdebug config errors in the logs but breakpoints are still not working with vscode, going to try exposing port 9000 on the container.

Error log:

[Sun Feb 21 14:05:48.721150 2021] [php7:notice] [pid 250] [client 172.19.0.1:59306] Xdebug: [Step Debug] Time-out connecting to debugging client, waited: 200 ms. Tried: host.docker.internal:9003 (through xdebug.client_host/xdebug.client_port) :-(, referer: http://localhost:8300/interface/main/tabs/main.php?token_main=MYTBpRjjcWpfYJJbkmL60E5RNe4RwDyOwsdsFyTZ
[Sun Feb 21 14:05:48.920556 2021] [php7:notice] [pid 17] [client 172.19.0.1:59308] Xdebug: [Step Debug] Time-out connecting to debugging client, waited: 200 ms. Tried: host.docker.internal:9003 (through xdebug.client_host/xdebug.client_port) :-(, referer: http://localhost:8300/interface/main/tabs/main.php?token_main=MYTBpRjjcWpfYJJbkmL60E5RNe4RwDyOwsdsFyTZ
[Sun Feb 21 14:05:51.131311 2021] [php7:notice] [pid 17] [client 172.19.0.1:59308] Xdebug: [Step Debug] Time-out connecting to debugging client, waited: 200 ms. Tried: host.docker.internal:9003 (through xdebug.client_host/xdebug.client_port) :-(, referer: http://localhost:8300/interface/main/messages/messages.php?form_active=1
[Sun Feb 21 14:07:04.752509 2021] [ssl:warn] [pid 36] AH01906: 172.19.0.6:443:0 server certificate is a CA certificate (BasicConstraints: CA == TRUE !?)
[Sun Feb 21 14:07:04.752519 2021] [ssl:warn] [pid 36] AH01909: 172.19.0.6:443:0 server certificate does NOT include an ID which matches the server name
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 172.19.0.6. Set the 'ServerName' directive globally to suppress this message
Xdebug: [Config] The setting 'xdebug.profiler_enable' has been renamed, see the upgrading guide at https://xdebug.org/docs/upgrade_guide#changed-xdebug.profiler_enable (See: https://xdebug.org/docs/errors#CFG-C-CHANGED)
Xdebug: [Config] The setting 'xdebug.profiler_enable_trigger' has been renamed, see the upgrading guide at https://xdebug.org/docs/upgrade_guide#changed-xdebug.profiler_enable_trigger (See: https://xdebug.org/docs/errors#CFG-C-CHANGED)
Xdebug: [Config] The setting 'xdebug.profiler_output_dir' has been renamed, see the upgrading guide at https://xdebug.org/docs/upgrade_guide#changed-xdebug.profiler_output_dir (See: https://xdebug.org/docs/errors#CFG-C-CHANGED)
Xdebug: [Config] The setting 'xdebug.remote_connect_back' has been renamed, see the upgrading guide at https://xdebug.org/docs/upgrade_guide#changed-xdebug.remote_connect_back (See: https://xdebug.org/docs/errors#CFG-C-CHANGED)
Xdebug: [Config] The setting 'xdebug.remote_enable' has been renamed, see the upgrading guide at https://xdebug.org/docs/upgrade_guide#changed-xdebug.remote_enable (See: https://xdebug.org/docs/errors#CFG-C-CHANGED)
Xdebug: [Config] The setting 'xdebug.remote_log' has been renamed, see the upgrading guide at https://xdebug.org/docs/upgrade_guide#changed-xdebug.remote_log (See: https://xdebug.org/docs/errors#CFG-C-CHANGED)
Xdebug: [Config] The setting 'xdebug.remote_port' has been renamed, see the upgrading guide at https://xdebug.org/docs/upgrade_guide#changed-xdebug.remote_port (See: https://xdebug.org/docs/errors#CFG-C-CHANGED)
[Sun Feb 21 14:07:04.763706 2021] [ssl:warn] [pid 36] AH01906: 172.19.0.6:443:0 server certificate is a CA certificate (BasicConstraints: CA == TRUE !?)
[Sun Feb 21 14:07:04.763714 2021] [ssl:warn] [pid 36] AH01909: 172.19.0.6:443:0 server certificate does NOT include an ID which matches the server name
[Sun Feb 21 14:07:04.765057 2021] [mpm_prefork:notice] [pid 36] AH00163: Apache/2.4.46 (Unix) OpenSSL/1.1.1i configured -- resuming normal operations 
[Sun Feb 21 14:07:04.765071 2021] [core:notice] [pid 36] AH00094: Command line: '/usr/sbin/httpd -D FOREGROUND'
[Sun Feb 21 14:19:21.231687 2021] [php7:notice] [pid 47] [client 172.19.0.1:59484] PHP Warning:  Division by zero in /var/www/localhost/htdocs/openemr/interface/login/login.php on line 11
[Sun Feb 21 14:19:21.231707 2021] [php7:notice] [pid 47] [client 172.19.0.1:59484] PHP Stack trace:
[Sun Feb 21 14:19:21.231711 2021] [php7:notice] [pid 47] [client 172.19.0.1:59484] PHP   1. {main}() /var/www/localhost/htdocs/openemr/interface/login/login.php:0
[Sun Feb 21 14:21:43.250158 2021] [php7:notice] [pid 40] [client 172.19.0.1:59492] PHP Warning:  Division by zero in /var/www/localhost/htdocs/openemr/interface/login/login.php on line 11
[Sun Feb 21 14:21:43.250178 2021] [php7:notice] [pid 40] [client 172.19.0.1:59492] PHP Stack trace:
[Sun Feb 21 14:21:43.250182 2021] [php7:notice] [pid 40] [client 172.19.0.1:59492] PHP   1. {main}() /var/www/localhost/htdocs/openemr/interface/login/login.php:0
[Sun Feb 21 14:21:45.002453 2021] [php7:notice] [pid 40] [client 172.19.0.1:59492] PHP Warning:  Division by zero in /var/www/localhost/htdocs/openemr/interface/login/login.php on line 11
[Sun Feb 21 14:21:45.002470 2021] [php7:notice] [pid 40] [client 172.19.0.1:59492] PHP Stack trace:
[Sun Feb 21 14:21:45.002474 2021] [php7:notice] [pid 40] [client 172.19.0.1:59492] PHP   1. {main}() /var/www/localhost/htdocs/openemr/interface/login/login.php:0
[Sun Feb 21 14:21:45.219398 2021] [php7:notice] [pid 40] [client 172.19.0.1:59492] PHP Warning:  Division by zero in /var/www/localhost/htdocs/openemr/interface/login/login.php on line 11
[Sun Feb 21 14:21:45.219414 2021] [php7:notice] [pid 40] [client 172.19.0.1:59492] PHP Stack trace:
[Sun Feb 21 14:21:45.219418 2021] [php7:notice] [pid 40] [client 172.19.0.1:59492] PHP   1. {main}() /var/www/localhost/htdocs/openemr/interface/login/login.php:0
[Sun Feb 21 14:21:56.839051 2021] [php7:notice] [pid 42] [client 172.19.0.1:59494] PHP Warning:  Division by zero in /var/www/localhost/htdocs/openemr/interface/login/login.php on line 11
[Sun Feb 21 14:21:56.839069 2021] [php7:notice] [pid 42] [client 172.19.0.1:59494] PHP Stack trace:
[Sun Feb 21 14:21:56.839072 2021] [php7:notice] [pid 42] [client 172.19.0.1:59494] PHP   1. {main}() /var/www/localhost/htdocs/openemr/interface/login/login.php:0
[Sun Feb 21 14:21:57.524428 2021] [php7:notice] [pid 42] [client 172.19.0.1:59494] PHP Warning:  Division by zero in /var/www/localhost/htdocs/openemr/interface/login/login.php on line 11
[Sun Feb 21 14:21:57.524444 2021] [php7:notice] [pid 42] [client 172.19.0.1:59494] PHP Stack trace:
[Sun Feb 21 14:21:57.524448 2021] [php7:notice] [pid 42] [client 172.19.0.1:59494] PHP   1. {main}() /var/www/localhost/htdocs/openemr/interface/login/login.php:0
[Sun Feb 21 14:22:21.372740 2021] [php7:notice] [pid 44] [client 172.19.0.1:59498] PHP Warning:  Division by zero in /var/www/localhost/htdocs/openemr/interface/login/login.php on line 11
[Sun Feb 21 14:22:21.372759 2021] [php7:notice] [pid 44] [client 172.19.0.1:59498] PHP Stack trace:
[Sun Feb 21 14:22:21.372763 2021] [php7:notice] [pid 44] [client 172.19.0.1:59498] PHP   1. {main}() /var/www/localhost/htdocs/openemr/interface/login/login.php:0
[Sun Feb 21 14:25:09.224623 2021] [php7:notice] [pid 37] [client 172.19.0.1:59508] PHP Warning:  Division by zero in /var/www/localhost/htdocs/openemr/interface/login/login.php on line 12
[Sun Feb 21 14:25:09.224640 2021] [php7:notice] [pid 37] [client 172.19.0.1:59508] PHP Stack trace:
[Sun Feb 21 14:25:09.224644 2021] [php7:notice] [pid 37] [client 172.19.0.1:59508] PHP   1. {main}() /var/www/localhost/htdocs/openemr/interface/login/login.php:0
[Sun Feb 21 14:25:47.893950 2021] [php7:notice] [pid 45] [client 172.19.0.1:59510] PHP Warning:  Division by zero in /var/www/localhost/htdocs/openemr/interface/login/login.php on line 12
[Sun Feb 21 14:25:47.893967 2021] [php7:notice] [pid 45] [client 172.19.0.1:59510] PHP Stack trace:
[Sun Feb 21 14:25:47.893971 2021] [php7:notice] [pid 45] [client 172.19.0.1:59510] PHP   1. {main}() /var/www/localhost/htdocs/openemr/interface/login/login.php:0
[Sun Feb 21 14:26:52.060586 2021] [php7:notice] [pid 46] [client 172.19.0.1:59520] PHP Warning:  Division by zero in /var/www/localhost/htdocs/openemr/interface/login/login.php on line 12
[Sun Feb 21 14:26:52.060613 2021] [php7:notice] [pid 46] [client 172.19.0.1:59520] PHP Stack trace:
[Sun Feb 21 14:26:52.060619 2021] [php7:notice] [pid 46] [client 172.19.0.1:59520] PHP   1. {main}() /var/www/localhost/htdocs/openemr/interface/login/login.php:0
[Sun Feb 21 14:54:35.682383 2021] [php7:notice] [pid 42] [client 172.19.0.1:59790] PHP Warning:  Division by zero in /var/www/localhost/htdocs/openemr/interface/login/login.php on line 14
[Sun Feb 21 14:54:35.682400 2021] [php7:notice] [pid 42] [client 172.19.0.1:59790] PHP Stack trace:
[Sun Feb 21 14:54:35.682403 2021] [php7:notice] [pid 42] [client 172.19.0.1:59790] PHP   1. {main}() /var/www/localhost/htdocs/openemr/interface/login/login.php:0

Ok I got it to work but the docker image needs to be updated in order for it to work, so if you docker-compose down you will have to edit the xdebug.ini again.

Here’s what I did:

  1. Install PHP Debug in vscode
  2. Create a launch.json file in your vscode workspace with the following:
{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [    
      {
        "name": "Listen for XDebug",
        "type": "php",
        "request": "launch",
        "port": 9003,
        "externalConsole": false,
        "log": true,
        "pathMappings": {
          "/var/www/localhost/htdocs/openemr": "${workspaceRoot}"
        },
        "ignore": [
          "**/vendor/**/*.php"
        ]      
      },
      {
        "name": "Launch currently open script",
        "type": "php",
        "request": "launch",
        "program": "${file}",
        "cwd": "${fileDirname}",
        "port": 9003
    }
    ]
  }
  1. Install xdebug helper browser plugin for chrome for firefox
  2. Run docker-compose up in the openemr/docker/development-easy/ folder
  3. Run docker ps -a to get the container ID usually the one that says openemr/openemr:flex under image
  4. Run docker exec -it container_id_goes_here /bin/sh - replace container_id_goes_here with your container id from previous step
  5. Once in the docker container run cd /etc/php/conf.d/
  6. Once in the conf.d directory run vi 50_xedubg.ini
  7. Press the insert key or the letter i on your keyboard to enter edit mode and paste the following code to 50_xedebug.ini:
    xdebug.client_host=host.docker.internal
    xdebug.mode=debug
    
  8. Press the esc then type :wq to write and quit vim
  9. Exit the container and run docker-compose restart in the openemr/docker/development-easy/ folder
  10. You should now be able to debug PHP in VSCode.

@brady.miller I tried passing these values as environment variables in the docker-compose.yml file but it doesn’t work, it would be nice to enable this via env vars that way there’s no need to edit the xedebug.ini but I will let you decide what is best. This needs to be fixed and documented so we can get people onboard to checkout the repo and start coding without any issues.

I made a github issue for this: Ensure docker development easy works with xdebug and vscode · Issue #285 · openemr/openemr-devops · GitHub

Thanks to all those involved.

1 Like