Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build php-fpm Xdebug #2848

Closed
AndreiiP opened this issue Feb 24, 2021 · 11 comments
Closed

build php-fpm Xdebug #2848

AndreiiP opened this issue Feb 24, 2021 · 11 comments

Comments

@AndreiiP
Copy link

AndreiiP commented Feb 24, 2021

Description:

php 7.4
When I build php-fpm I get in phpinfo (Xdebug v2.9.8). But Xdebug doesn't work. If I take a folder (php-fpm) from an old project in which I did the same build, then Xdebug starts working. What could be the reason?

This program makes use of the Zend Scripting Language Engine: Zend Engine v3.4.0, Copyright (c) Zend Technologies with Zend OPcache v7.4.13, Copyright (c), by Zend Technologies with Xdebug v2.9.8, Copyright (c) 2002-2020, by Derick Rethans

Expected Behavior:

Context information:

Output of git rev-parse HEAD

{paste here}

Output of docker version

Docker version 20.10.2, build 2291f61

Output of docker-compose version

docker-compose version 1.24.1, build 4667896b

System info: Mac, Windows or Linux. Include which disto/version

ubuntu 18

Steps to reproduce the issue:

  1. docker-compose build --no-cache php-fpm
  2. Xdebug doesn't work.

phpinfo() http://i.imgur.com/iEPmm82.png

@andrewwongyedpay
Copy link

andrewwongyedpay commented May 13, 2021

Please try the following:

In php-fpm/xdebug.ini

xdebug.remote_host="172.17.0.1"
xdebug.remote_connect_back=0

In docker-compose.yml, remove the line
- "${PHP_FPM_XDEBUG_PORT}:9003"

After the changes, run
docker-compose build --no-cache

@Sogl
Copy link
Contributor

Sogl commented May 25, 2021

@andrewwongyedpay Didn't work for me. Any ideas?

@andrewwongyedpay
Copy link

@andrewwongyedpay Didn't work for me. Any ideas?

It is difficult to tell what didn't work if no error message is provided.

  1. Is xdebug enabled inside docker? In which service (php-fpm / workspace)?
  2. Did you receive any error message when docker-compose up?
  3. What is your OS? OSX and Window may need remote_connect_back=1, on Linux remote_connect_back should be 0.

@Sogl
Copy link
Contributor

Sogl commented May 26, 2021

  1. Enabled in both php-fpm and workspace
  2. No error messages.
  3. OSX, but I have xdebug.remote_connect_back=0

My full file:

; NOTE: The actual debug.so extention is NOT SET HERE but rather (/usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini)

xdebug.remote_host="host.docker.internal"
xdebug.remote_connect_back=0
xdebug.remote_port=9000
xdebug.idekey=PHPSTORM

xdebug.remote_autostart=0
xdebug.remote_enable=0
xdebug.cli_color=0
xdebug.profiler_enable=0
xdebug.profiler_output_dir="~/xdebug/phpstorm/tmp/profiling"

xdebug.remote_handler=dbgp
xdebug.remote_mode=req

xdebug.var_display_max_children=-1
xdebug.var_display_max_data=-1
xdebug.var_display_max_depth=-1

@andrewwongyedpay
Copy link

andrewwongyedpay commented May 26, 2021

  1. Enabled in both php-fpm and workspace
  2. No error messages.
  3. OSX, but I have xdebug.remote_connect_back=0

My full file:

; NOTE: The actual debug.so extention is NOT SET HERE but rather (/usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini)

xdebug.remote_host="host.docker.internal"
xdebug.remote_connect_back=0
xdebug.remote_port=9000
xdebug.idekey=PHPSTORM

xdebug.remote_autostart=0
xdebug.remote_enable=0
xdebug.cli_color=0
xdebug.profiler_enable=0
xdebug.profiler_output_dir="~/xdebug/phpstorm/tmp/profiling"

xdebug.remote_handler=dbgp
xdebug.remote_mode=req

xdebug.var_display_max_children=-1
xdebug.var_display_max_data=-1
xdebug.var_display_max_depth=-1

The setting looks correct to me if your ide is listening on port 9000.
However, it is usually used by php-fpm in your host environment, so your ide may not able to start the debug client.
Would you share your ide setting?

@Sogl
Copy link
Contributor

Sogl commented May 26, 2021

  1. Deployment
    image

  2. CLI
    image

2.1. CLI 2nd image
image

  1. Xdebug validate
    image

  2. PHP Servers
    image

  3. Configuration
    image

  4. My port now is 9000
    image

  5. Breakpoints in code
    image

  6. I use this button to start debug
    image

  7. My browser open URL http://sogl.lar/?XDEBUG_SESSION_START=18293 but breakpoints are not active.

@andrewwongyedpay
Copy link

andrewwongyedpay commented May 26, 2021

xdebug.remote_autostart=1
xdebug.remote_enable=1

And rebuild the container

@Sogl
Copy link
Contributor

Sogl commented May 26, 2021

Not working. I did all my changes in php_fpm\xdebug.ini

I also tried to bring back writing log:
4893347

with this line xdebug.remote_log=/var/log/php/xdebug_remote.log

But errors:

➜  laradock git:(master) ✗ docker-compose logs php-fpm
Attaching to laradock_php-fpm_1
php-fpm_1              | [26-May-2021 10:37:00] NOTICE: fpm is running, pid 1
php-fpm_1              | [26-May-2021 10:37:00] NOTICE: ready to handle connections
php-fpm_1              | NOTICE: PHP message: Xdebug could not open the remote debug file '/var/log/php/xdebug_remote.log'.
php-fpm_1              | 172.19.0.6 -  26/May/2021:10:38:52 +0000 "GET /index.php" 200
php-fpm_1              | NOTICE: PHP message: Xdebug could not open the remote debug file '/var/log/php/xdebug_remote.log'.
php-fpm_1              | NOTICE: PHP message: Xdebug could not open the remote debug file '/var/log/php/xdebug_remote.log'.
php-fpm_1              | NOTICE: PHP message: Xdebug could not open the remote debug file '/var/log/php/xdebug_remote.log'.
php-fpm_1              | NOTICE: PHP message: Xdebug could not open the remote debug file '/var/log/php/xdebug_remote.log'.
php-fpm_1              | NOTICE: PHP message: Xdebug could not open the remote debug file '/var/log/php/xdebug_remote.log'.
php-fpm_1              | 172.19.0.6 -  26/May/2021:10:38:55 +0000 "GET /index.php" 200
php-fpm_1              | NOTICE: PHP message: Xdebug could not open the remote debug file '/var/log/php/xdebug_remote.log'.
php-fpm_1              | NOTICE: PHP message: Xdebug could not open the remote debug file '/var/log/php/xdebug_remote.log'.
php-fpm_1              | NOTICE: PHP message: Xdebug could not open the remote debug file '/var/log/php/xdebug_remote.log'.
php-fpm_1              | 172.19.0.6 -  26/May/2021:10:38:55 +0000 "GET /index.php" 200
php-fpm_1              | NOTICE: PHP message: Xdebug could not open the remote debug file '/var/log/php/xdebug_remote.log'.
php-fpm_1              | NOTICE: PHP message: Xdebug could not open the remote debug file '/var/log/php/xdebug_remote.log'.
php-fpm_1              | NOTICE: PHP message: Xdebug could not open the remote debug file '/var/log/php/xdebug_remote.log'.
php-fpm_1              | NOTICE: PHP message: Xdebug could not open the remote debug file '/var/log/php/xdebug_remote.log'.
php-fpm_1              | 172.19.0.6 -  26/May/2021:10:39:29 +0000 "GET /index.php" 200
php-fpm_1              | NOTICE: PHP message: Xdebug could not open the remote debug file '/var/log/php/xdebug_remote.log'.
php-fpm_1              | 172.19.0.6 -  26/May/2021:10:39:51 +0000 "GET /index.php" 200

@Sogl
Copy link
Contributor

Sogl commented May 26, 2021

Also found this error in Debug console:
image

UPDATE

FINALLY IT WORKS using this answer from SO: https://stackoverflow.com/a/48977305/4827198

image

My xdebug.ini:

; NOTE: The actual debug.so extention is NOT SET HERE but rather (/usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini)

xdebug.remote_host="host.docker.internal"
xdebug.remote_connect_back=0
xdebug.remote_port=9000
xdebug.idekey=PHPSTORM

xdebug.remote_autostart=1
xdebug.remote_enable=1
xdebug.cli_color=0
xdebug.profiler_enable=0
xdebug.profiler_output_dir="~/xdebug/phpstorm/tmp/profiling"
xdebug.remote_log=/tmp/xdebug_remote.log

xdebug.remote_handler=dbgp
xdebug.remote_mode=req

xdebug.var_display_max_children=-1
xdebug.var_display_max_data=-1
xdebug.var_display_max_depth=-1

Also I can view xdebug logs using two commands:


docker-compose exec php-fpm bash
tail -f /tmp/xdebug_remote.log

P.S. Sometimes I see this warning in PHPStorm:


Debug session was finished without being paused
It may be caused by path mappings misconfiguration or not synchronized local and remote projects.
To figure out the problem check path mappings configuration for 'laradock' server at PHP|Servers 
or enable Break at first line in PHP scripts option (from Run menu).

I disabled Notify if debug session was finished without been paused. It works for me.

@stale
Copy link

stale bot commented Aug 24, 2021

Hi 👋 this issue has been automatically marked as stale 📌 because it has not had recent activity 😴. It will be closed if no further activity occurs. Thank you for your contributions ❤️.

@stale stale bot added the Stale label Aug 24, 2021
@stale
Copy link

stale bot commented Sep 14, 2021

Hi again 👋 we would like to inform you that this issue has been automatically closed 🔒 because it had not recent activity during the stale period. We really really appreciate your contributions, and looking forward for more in the future 🎈.

@stale stale bot closed this as completed Sep 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants