6

I use PHPStorm along with Xdebug to step through my code. PHPStorm is running on a Windows 7 machine, and my local webserver is running on a separate CentOS 6.4 machine. I've done a phpinfo(); to verify that Xdebug is being loaded by PHP, and it is. The following are the settings for my Xdebug in the PHP.ini:

    [xdebug]
    zend_extension="/usr/lib/php/modules/xdebug.so"
    xdebug.remote_enable = 1
    xdebug.remote_port = 9000
    xdebug.remote_host = "192.168.1.130"
    xdebug.remote_log = "/var/log/httpd/xdebug_log"
    
I similarly setup PHPStorm to use my CentOS server as the debugging server, and I listen for connections. I assigned static IPs to both of these machines. Using a Chrome Xdebug plugin to set the appropriate cookies, I attempt to set a breakpoint, but nothing happens. When I go to look in /var/log/httpd/xdebug_log (which has 777 permissions), nothing is written there. I've opened up port 9000, and I can telnet from my CentOS machine back to my Windows machine on port 9000 no problem. I also set SELinux to permissive, but to no avail.

Any ideas what could be happening here?

Dave
  • 439
  • 1
  • 6
  • 18
  • 1
    Well ... if you have NOTHING in xdebug_log file ... then xdebug simply not getting debug request (cookie/get/post parameter etc). You can FORCE debug mode: `xdebug_break();` to programmaticaly hit breakpoint or with `xdebug.remote_connect_back = 1` or `xdebug.remote_autostart = 1` (check docs for details). SELinux definitely can cause issues (not expert at all in this regard). In any case, have a look at this as well: http://blog.jetbrains.com/phpstorm/2013/07/webinar-recording-debugging-php-with-phpstorm/ – LazyOne Jul 30 '13 at 09:59
  • I tried your suggestions, but still no luck. when I call `xdebug_var_dump()` or `xdebug_is_enabled()`, I'm getting values indicating that xdebug is working. However, PHPStorm is not connecting. I've quadruple checked my remote server settings, and I can 100% tell you that they are correct. – Dave Jul 31 '13 at 23:08
  • I'm shaking my head at myself... I rebooted CentOS, and all is working now. Ugh, I really need to start following my own advice and try a reboot before wasting your guys' time ;-) – Dave Jul 31 '13 at 23:27
  • This is not a waste of time, this is a valid solution to your problem and an important reminder to always 'check the plug'. – nick fox Jun 28 '15 at 14:36

5 Answers5

8

Try to configure your project in PhpStorm

  1. Open Settings->Languages & Frameworks->PHP->Debug
  2. Uncheck the "Ignore external connections through unregistered server configurations" option
  3. OK
Jekis
  • 4,274
  • 2
  • 36
  • 42
  • could you please add a "why this works" to this answer? – Christopher Thomas Apr 12 '21 at 18:56
  • Checkbox "Ignore external connections through unregistered server configurations" means that domain name of your local website (you trying to debug) must be listed in the PHP -> Servers (in phpstrom config). If no, then your website will be ignored by phpstorm. – Jekis Apr 14 '21 at 06:51
3

Add to your php.ini:

xdebug.mode=debug

Jeremy
  • 3,620
  • 9
  • 43
  • 75
3

I was having the same issue, below are the steps I performed to resolve it:

  1. Make sure you have xdebug installed and in php.ini uncomment xdebug.mode=debug
  2. Open Settings->Languages & Frameworks->PHP->Debug, Assign Debug Port value, you can find this port from php.ini. In my case, it was 9002
  3. Now Validate debugger configurations - here you need to add the path to your web application files and URL. Click validate.
  4. Now Start Listening -> Enable listening for PHP Debug Connection.

After this setup you can set a break point and start debugging with XDEBUG.

mk23
  • 1,257
  • 1
  • 12
  • 25
0

In my case, i added folder that im debugging to exclusive, so it return 502 or blank page when i put breakpoint. Remove exclusive folder and everything working.

You can consider this blog to find more solution: Link.

Igris Dankey
  • 383
  • 2
  • 6
0
sudo gedit /etc/php/7.2/mods-available/xdebug.ini

zend_extension=xdebug.so
xdebug.remote_enable = 1
xdebug.remote_port = 9898
xdebug.idekey = “PHPSTORM”
xdebug.show_error_trace = 1
xdebug.remote_autostart = 0
xdebug.mode=debug
xdebug.client_port=9898
moazzams
  • 27
  • 2
  • While this code may answer the question, providing additional context regarding why and/or how this code answers the question improves its long-term value. – Donald Duck Oct 19 '22 at 12:33