Xdebug setup help

I'm having issues setting up Xdebug 2.7. Restarting Phpstorm 2019.1 does not show an Xdebug dialog. I'm on Lubuntu 18.04 with php 7.2.15 and Apache2. 

- Chrome debugger extension set to "debug" on target site for the project

- /etc/php/7.2/cli/php.ini is the config file being used in Phpstorm settings 

- port is set to 9000 in php.ini

Screenshots are given below:

15 comments

Hi there,

Collect and provide Xdebug log for such unsuccessful debug session. It will have clues at what might be wrong.

As it stands right now: you are on Linux .. so quite high chances to have php-fpm installed as well. It uses the same TCP 9000 port as Xdebug ... so it's possible that Xdebug connects to php-fpm instead of IDE.

0

Is this the log you want?

owner@G700:~$ netstat -anp | grep CLOSE_WAIT
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
tcp 1 0 192.168.1.33:58622 117.18.237.29:80 CLOSE_WAIT 3638/chrome --type=
tcp 1 0 192.168.1.33:58624 117.18.237.29:80 CLOSE_WAIT 3638/chrome --type=
tcp 1 0 192.168.1.33:44910 54.236.121.227:443 CLOSE_WAIT 2655/dropbox
tcp 32 0 192.168.1.33:53436 162.125.34.6:443 CLOSE_WAIT 2655/dropbox
tcp 32 0 192.168.1.33:39216 162.125.81.7:443 CLOSE_WAIT 2655/dropbox
tcp 32 0 192.168.1.33:48188 195.154.252.118:443 CLOSE_WAIT 3638/chrome --type=
tcp 32 0 192.168.1.33:44468 162.125.81.3:443 CLOSE_WAIT 2655/dropbox
tcp 32 0 192.168.1.33:46346 162.125.81.3:443 CLOSE_WAIT 2655/dropbox

 

I have changed the port to 9004 in php.ini and phpstorm xdebug settings.

0

>Is this the log you want?

https://xdebug.org/docs/all_settings#remote_log

P.S. Just in case: make sure that you are editing the right php.ini file: on Linux it's very common to have one for CLI and different one used by Apache.

0

How do I switch the php.ini file being used by Phpstorm. You can see above that Phpstorm uses the one in the CLI directory

0

PhpStorm does NOT use any php.ini files. It simply reports whatever PHP Interpreter detects/uses. PHP Interpreter in PhpStorm is NOT used for executing web requests .. especially if you have Apache web server that serves your web pages.

Apache is different here. Run phpinfo() via web browser and see what php.ini it uses and edit that file.

0

phpinfo() points to: /etc/php/7.2/apache2/php.ini

But you can see in the 2nd image in my previous comment this is not the config file used by the interpreter in Phpstorm. The one Phpstorm uses is in the CLI folder. Which seems to be an issue.

I only have php 7.2.15 on my computer.

0

What are you trying to debug: a PHP script in CLI mode... or a web page?

If it's a web page then ignore PHP Interpreter altogether as it does not participate in web page debug and focus on settings from /etc/php/7.2/apache2/php.ini

0

in my config file at /etc/php/apache2/php.ini , I noticed the following settings were already present:

zend_extension = /usr/lib/php/20170718/xdebug.so
xdebug.remote_enable=1
xdebug.remote_port=9000
xdebug.remote_connect_back=1

 

I added/changed:

xdebug.remote_port=9004
xdebug.remote_log="xdebugRemoteLog"

 

Restarting Phpstorm I notice no changes, no dialog popup. Also, I do not see "xdebugRemoteLog" in the above php config file directory. I can not locate it using 'whereis' either.

0

I have noticed an Xdebug error pushed to the screen (for something that is a legitimate error, not revolving around Xdebug itself):

 

( ! ) Xdebug: Fatal error: Uncaught Error: Class 'MyGlobals' not found in /var/www/html/wptest2/wp-content/plugins/frequentVisitorCoupons/classes/utilities.php:51 Stack trace: #0 /var/www/html/wptest2/wp-includes/class-wp-hook.php(286): Utilities::createTablesIfNotExists('') #1 /var/www/html/wptest2/wp-includes/class-wp-hook.php(310): WP_Hook->apply_filters('', Array) #2 /var/www/html/wptest2/wp-includes/plugin.php(465): WP_Hook->do_action(Array) #3 /var/www/html/wptest2/wp-admin/plugins.php(177): do_action('activate_freque...') #4 {main} thrown in /var/www/html/wptest2/wp-content/plugins/frequentVisitorCoupons/classes/utilities.php on line 51. Output triggered in /var/www/html/wptest2/wp-content/plugins/query-monitor/collectors/php_errors.php on line 166
Call Stack
# Time Memory Function Location
1 0.3994 7136808 QM_Collector_PHP_Errors->shutdown_handler( ) .../php_errors.php:0
2 0.3995 7139088 xdebug_print_function_stack ( ) .../php_errors.php:166

0

What exactly do you do to start a debugging session? Since it's Wordpress, I suppose you want to debug in the web mode. Just in case, please make sure you're doing everything in accordance to https://www.jetbrains.com/help/phpstorm/zero-configuration-debugging.html

Then, you have changed xdebug.remote_port to 9004. Did you reflect this change in PhpStorm at Settings | Languages & Frameworks | PHP | Debug?

And the Xdebug remote log still would be nice. Please note that you configured it wrong, xdebug.remote_log="xdebugRemoteLog" won't do anything. Please follow this guide to create and collect the Xdebug log: https://intellij-support.jetbrains.com/hc/en-us/articles/206544819-How-to-collect-remote-log-for-XDebug

0

I have the zero config debug setup. I installed the chrome debug extension and set it to "debug" on localhost. It now appears green on localhost

 

you have changed xdebug.remote_port to 9004. Did you reflect this change in PhpStorm at Settings | Languages & Frameworks | PHP | Debug?

I have yes

0

Then we definitely need to take a look at the Xdebug log. Please configure it and upload somewhere. Thank you!

0

Under what conditions will a debug file or entry get created? I do not see the folder or file being generated in the location specified in php.ini

0

It's created each time a debug session starts as long as the directory has write permissions for the user running the web server / interpreter.
Usually, it's easier just to create the file manually and set 777 permissions for it.

0

Please sign in to leave a comment.