Frustration getting Xdebug and PHPStorm 3.0 to talk to each other :(

Hey folks,

After the best part of 2 days trying to get this resolved, I'm hoping someone can offer me some advice!

I have a remote linux server, on which I have installed Xdebug.  (the web-based Xdebug installation checker gives it a thumbs-up)

However, I cannot seem to get PHPStorm 3.0 to hook up with it.

I have tried the http://blog.jetbrains.com/webide/2011/02/zero-configuration-debugging-with-xdebug-and-phpstorm-2-0/, but after refreshing the page, I expect PHPStorm to spring into action after listening for incoming connections.  But nothing happens.

I have read in a previous post on this form that the value for "xdebug.remote_host" should be the IP address of my Windows desktop machine, and NOT "localhost" (as is shown below). I have tried both options, with differing results.

>> "xdebug.remote_host=localhost" - entering the URL http://mysite.com/index.php?XDEBUG_SESSION_START=PHPSTORM returns straight away with the web page, and a new XDEBUG_SESSION cookie is dropped.  But nothing happens within PHP Storm.

>> "xdebug.remote_host=my_desktop_ip" (as recommended in another post) -  entering the URL http://mysite.com/index.php?XDEBUG_SESSION_START=PHPSTORM causes the browser to wait, and wait, and wait... (for several minutes) for a page to be returned, if one is returned at all.

Can anyone suggest anything I might try?

Any advice gratefully received  :)

Below is the phpinfo relating to Xdebug on the remote server.

xdebug

xdebug support

enabled

Version

2.1.2

Supported protocols

Revision

DBGp -   Common DeBuGger Protocol

$Revision:   1.145 $

Directive

Local Value

Master Value

xdebug.auto_trace

Off

Off

xdebug.collect_assignments

Off

Off

xdebug.collect_includes

On

On

xdebug.collect_params

0

0

xdebug.collect_return

Off

Off

xdebug.collect_vars

Off

Off

xdebug.default_enable

On

On

xdebug.dump.COOKIE

no   value

no   value

xdebug.dump.ENV

no   value

no   value

xdebug.dump.FILES

no   value

no   value

xdebug.dump.GET

no   value

no   value

xdebug.dump.POST

no   value

no   value

xdebug.dump.REQUEST

no   value

no   value

xdebug.dump.SERVER

no   value

no   value

xdebug.dump.SESSION

no   value

no   value

xdebug.dump_globals

On

On

xdebug.dump_once

On

On

xdebug.dump_undefined

Off

Off

xdebug.extended_info

On

On

xdebug.file_link_format

no   value

no   value

xdebug.idekey

PHPSTORM

PHPSTORM

xdebug.manual_url

http://www.php.net

http://www.php.net

xdebug.max_nesting_level

100

100

xdebug.overload_var_dump

On

On

xdebug.profiler_aggregate

Off

Off

xdebug.profiler_append

Off

Off

xdebug.profiler_enable

Off

Off

xdebug.profiler_enable_trigger

Off

Off

xdebug.profiler_output_dir

/tmp

/tmp

xdebug.profiler_output_name

cachegrind.out.%p

cachegrind.out.%p

xdebug.remote_autostart

Off

Off

xdebug.remote_connect_back

Off

Off

xdebug.remote_cookie_expire_time

3600

3600

xdebug.remote_enable

On

On

xdebug.remote_handler

dbgp

dbgp

xdebug.remote_host

localhost

localhost

xdebug.remote_log

/usr/local/xdebug.log

/usr/local/xdebug.log

xdebug.remote_mode

req

req

xdebug.remote_port

9000

9000

xdebug.scream

Off

Off

xdebug.show_exception_trace

Off

Off

xdebug.show_local_vars

Off

Off

xdebug.show_mem_delta

Off

Off

xdebug.trace_format

0

0

xdebug.trace_options

0

0

xdebug.trace_output_dir

/tmp

/tmp

xdebug.trace_output_name

trace.%c

trace.%c

xdebug.var_display_max_children

128

128

xdebug.var_display_max_data

512

512

xdebug.var_display_max_depth

3

3

9 comments
Comment actions Permalink

Hi Joe,

xdebug.remote_host has to be IP of the machine where PhpStorm is running (desktop PC) -- it's xdebug who initiates connection, not other way around.

  1. Maybe you providing wrong IP address (quite common mistake) ?
  2. Please check your desktop firewall configuration (as PhpStorm is the one that will be receiving xdebug connection)
  3. Please check if you are able to connect from your Linux box to your desktop (Activate "Run | Start Listen PHP Debug Connections"; go to linux box and try to connect to PhpStorm with help of telnet).
  4. Make sure that xdebug port number in PhpStorm (File | Settings | PHP | Debug) is the same as in xdebug config (9000) as well as "Can accept external connections" is checked.


You can try setting xdebug.remote_connect_back = On .. so there will be no need to provide specific IP address as xdebug will connect back to calling IP -- more about this (pros & cons) here: http://xdebug.org/docs/all_settings#remote_connect_back

Another possible thing -- path mappings (File | Settings | PHP | Servers -> Use path mappings).

If none of the above helps, please provide debugger logs (ideally both):

0
Comment actions Permalink

Hi Andriy,

Thank you very much for the information.

xdebug.remote_host has to be IP of the machine where PhpStorm is running (desktop PC) -- it's xdebug who initiates connection, not other way around.

  1. Maybe you providing wrong IP address (quite common mistake) ?


I have now modified the setting of  xdebug.remote_host to show the public IP address of my broadband connection.

2. Please check your desktop firewall configuration (as PhpStorm is the one that will be receiving xdebug connection)


I have disabled the Windows Firewall, and ensured that port 9000 allows traffic in/out on the Linux server firewall.

But I have a question about how the incoming Xdebug connection finds its way to my particular PC. There are 3 or 4 different PCs connected to the network (mix of wired/wifi) - but of course, they all share the same public IP address.

How does the Xdebug connection find it's way to my PC, and not any of the others on the same network?

3. Please check if you are able to connect from your Linux box to your desktop (Activate "Run | Start Listen PHP Debug Connections"; go to linux box and try to connect to PhpStorm with help of telnet).


I attempted connecting from the Linux server back to my PC using Telnet (having disabled the Windows Firewall), without success - but it brings me back to the same question ... how does telnet connect to my particular PC on the network, and not any of the others?

4. Make sure that xdebug port number in PhpStorm (File | Settings | PHP | Debug) is the same as in xdebug config (9000) as well as "Can accept external connections" is checked.


Settings in PHPStorm are as you specify.

You can try setting xdebug.remote_connect_back = On .. so there will be no need to provide specific IP address as xdebug will connect back to calling IP -- more about this (pros & cons) here: http://xdebug.org/docs/all_settings#remote_connect_back

xdebug.remote_connect_back On On



I tried this, and got the same behaviour as previously, i.e. the page took around 3 minutes to return, which it did with a XDEBUG_SESSION cookie. But no activity from PHPStorm.

Another possible thing -- path mappings (File | Settings | PHP | Servers -> Use path mappings).

I currently don't have any servers defined in this section.  So, I added a new server as follows:

Name: www.mysite.com
Host: www.mysite.com
Port: 9000
Debugger: Xdebug
Use path mappings: checked
(I haven't specified any absolute paths on the server)

After making these changes, I cleared cookies, and retried. Same result (page returned after just more than 3 minutes), but nothing from PHPStorm.

If none of the above helps, please provide debugger logs (ideally both):


I added the following setting to php.ini to generate the log file.

xdebug.remote_log /tmp/xdebug.log /tmp/xdebug.log



I tried the sequence again, but no log file is being created.

For PHPStorm, I added the following into the log.xml file, as per the instructions:




<category name="#com.jetbrains.php.debug">
  <priority value="DEBUG"/>
</category>

I restarted PHPStorm, and repeated the process.


Same result - page returned in just over 3 minutes with cookie.

The output from the PHPStorm log file from the point of the restart is below:


2012-01-08 01:52:04,528 [      0]   INFO -        #com.intellij.idea.Main - ------------------------------------------------------ IDEA STARTED ------------------------------------------------------
2012-01-08 01:52:04,548 [     20]   INFO -        #com.intellij.idea.Main - Using "FocusKiller" library to prevent focus stealing.
2012-01-08 01:52:08,640 [   4112]   INFO - j.ide.plugins.PluginDescriptor - Cannot find plugin com.intellij resource-bundle: messages.WebIdeBundle
2012-01-08 01:52:10,760 [   6232]   INFO - llij.ide.plugins.PluginManager - 36 plugins initialized in 4288 ms
2012-01-08 01:52:10,760 [   6232]   INFO - llij.ide.plugins.PluginManager - Loaded plugins:IDEA CORE, Apache config (.htaccess) support (1.0), CSS Support, ASP (0.1), JavaScript Support (1.0), CoffeeScript (2.0), XPathView + XSLT Support (4), IntelliLang (8.0), Remote Hosts Access (0.1), UML Support (1.0), PHP (2), Command Line Tool Support, CVS Integration (0.1), Database Support (1.0), Git Integration (8.1), Task Management (1.0), GitHub, HAML, hg4idea (10.0), HTML Tools (2.0), JavaScript Debugger (1.0), Inspection-JS (2.0), JavaScript Intention Power Pack (0.9.4), Java Server Pages Integration (1.0), LESS support, Perforce Integration (2.0), Phing Support (1), QuirksMode, Refactor-X (2.01), SASS support, SQL support (1.0), Subversion Integration (1.0), TFS Integration (1.08.1), W3C Validators (2.0), XSLT-Debugger (1.4), YAML
2012-01-08 01:52:10,945 [   6417]   INFO - plication.impl.ApplicationImpl - Problem reading font data.
java.io.IOException: Problem reading font data.
 at java.awt.Font.createFont(Font.java:924)
 at com.intellij.openapi.application.impl.ApplicationImpl.a(ApplicationImpl.java:258)
 at com.intellij.openapi.application.impl.ApplicationImpl.<init>(ApplicationImpl.java:249)
 at com.intellij.openapi.application.ex.ApplicationManagerEx.createApplication(ApplicationManagerEx.java:39)
 at com.intellij.idea.IdeaApplication.<init>(IdeaApplication.java:84)
 at com.intellij.idea.IdeaUltimateApplication.<init>(IdeaUltimateApplication.java:14)
 at com.intellij.idea.MainImpl.a(MainImpl.java:179)
 at com.intellij.idea.MainImpl.access$000(MainImpl.java:35)
 at com.intellij.idea.MainImpl$2.proceed(MainImpl.java:166)
 at com.intellij.ide.a.e.x$4.run(x$4.java:338)
 at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
 at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:641)
 at java.awt.EventQueue.access$000(EventQueue.java:84)
 at java.awt.EventQueue$1.run(EventQueue.java:602)
 at java.awt.EventQueue$1.run(EventQueue.java:600)
 at java.security.AccessController.doPrivileged(Native Method)
 at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
 at java.awt.EventQueue.dispatchEvent(EventQueue.java:611)
 at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
 at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
 at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
 at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
 at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
 at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
2012-01-08 01:52:15,823 [  11295]   INFO - api.vfs.impl.local.FileWatcher - Starting file watcher: C:\Program Files (x86)\JetBrains\PhpStorm 3.0\bin\fsnotifier.exe
2012-01-08 01:52:15,827 [  11299]   INFO - api.vfs.impl.local.FileWatcher - Native file watcher is operational.
2012-01-08 01:52:16,058 [  11530]   INFO - mpl.win32.Win32LocalFileSystem - Native filesystem for Windows is operational
2012-01-08 01:52:16,341 [  11813]   INFO - s.impl.stores.FileBasedStorage - Document was not loaded for $APP_CONFIG$/path.macros.xml file is null
2012-01-08 01:52:16,341 [  11813]   INFO - .impl.stores.XmlElementStorage - Document was not loaded for $APP_CONFIG$/path.macros.xml
2012-01-08 01:52:17,205 [  12677]   INFO - s.impl.stores.FileBasedStorage - Document was not loaded for $APP_CONFIG$/ui.lnf.xml file is null
2012-01-08 01:52:17,205 [  12677]   INFO - .impl.stores.XmlElementStorage - Document was not loaded for $APP_CONFIG$/ui.lnf.xml
2012-01-08 01:52:20,520 [  15992]   INFO - ellij.project.impl.ProjectImpl - 18 project components initialized in 3102 ms
2012-01-08 01:52:20,521 [  15993]   INFO - .module.impl.ModuleManagerImpl - 0 modules loaded in 0 ms
2012-01-08 01:52:20,665 [  16137]   INFO - .intellij.ide.XmlRpcServerImpl - XmlRpc server listening at /127.0.0.1:63342
2012-01-08 01:52:21,149 [  16621]   INFO - s.impl.stores.FileBasedStorage - Document was not loaded for $APP_CONFIG$/macros.xml file is null
2012-01-08 01:52:21,149 [  16621]   INFO - .impl.stores.XmlElementStorage - Document was not loaded for $APP_CONFIG$/macros.xml
2012-01-08 01:52:21,177 [  16649]   INFO - s.impl.stores.FileBasedStorage - Document was not loaded for $APP_CONFIG$/quicklists.xml file is null
2012-01-08 01:52:21,177 [  16649]   INFO - .impl.stores.XmlElementStorage - Document was not loaded for $APP_CONFIG$/quicklists.xml
2012-01-08 01:52:24,381 [  19853]   INFO - s.impl.stores.FileBasedStorage - Document was not loaded for $APP_CONFIG$/phpServers.xml file is null
2012-01-08 01:52:24,382 [  19854]   INFO - .impl.stores.XmlElementStorage - Document was not loaded for $APP_CONFIG$/phpServers.xml
2012-01-08 01:52:24,400 [  19872]   INFO - pl.stores.ApplicationStoreImpl - 71 application components initialized in 13053 ms
2012-01-08 01:52:24,578 [  20050]   INFO - s.impl.stores.FileBasedStorage - Document was not loaded for $APP_CONFIG$/customization.xml file is null
2012-01-08 01:52:24,578 [  20050]   INFO - .impl.stores.XmlElementStorage - Document was not loaded for $APP_CONFIG$/customization.xml
2012-01-08 01:52:24,993 [  20465]   INFO - om.intellij.util.ProfilingUtil - Profiling agent is not enabled. Add -agentlib:yjpagent to idea.vmoptions if necessary to profile IDEA.
2012-01-08 01:52:25,453 [  20925]   INFO - ij.openapi.wm.impl.IdeRootPane - App initialization took 23310 ms
2012-01-08 01:52:30,042 [  25514]   INFO - ellij.project.impl.ProjectImpl - 110 project components initialized in 4001 ms
2012-01-08 01:52:30,294 [  25766]   INFO - .module.impl.ModuleManagerImpl - 1 modules loaded in 252 ms
2012-01-08 01:52:30,922 [  26394]   INFO - api.vfs.impl.local.FileWatcher - 2 paths checked, 0 mapped, 11 mks
2012-01-08 01:52:31,787 [  27259]   INFO - .roots.impl.DirectoryIndexImpl - Directory index initialized in 102 ms, indexed 1466 directories
2012-01-08 01:52:31,804 [  27276]   INFO - s.impl.stores.FileBasedStorage - Document was not loaded for $PROJECT_CONFIG_DIR$/sqldialects.xml file is null
2012-01-08 01:52:31,804 [  27276]   INFO - .impl.stores.XmlElementStorage - Document was not loaded for $PROJECT_CONFIG_DIR$/sqldialects.xml
2012-01-08 01:52:31,809 [  27281]   INFO - s.impl.stores.FileBasedStorage - Document was not loaded for $APP_CONFIG$/plainTextFiles.xml file is null
2012-01-08 01:52:31,810 [  27282]   INFO - .impl.stores.XmlElementStorage - Document was not loaded for $APP_CONFIG$/plainTextFiles.xml
2012-01-08 01:52:31,912 [  27384]   INFO - pl.PushedFilePropertiesUpdater - File properties pushed in 116 ms
2012-01-08 01:52:32,258 [  27730]   INFO - s.impl.stores.FileBasedStorage - Document was not loaded for $PROJECT_CONFIG_DIR$/phing.xml file is null
2012-01-08 01:52:32,259 [  27731]   INFO - .impl.stores.XmlElementStorage - Document was not loaded for $PROJECT_CONFIG_DIR$/phing.xml
2012-01-08 01:52:32,771 [  28243]   INFO - s.impl.stores.FileBasedStorage - Document was not loaded for $OPTIONS$/applicationLibraries.xml file is null
2012-01-08 01:52:32,771 [  28243]   INFO - .impl.stores.XmlElementStorage - Document was not loaded for $OPTIONS$/applicationLibraries.xml
2012-01-08 01:52:32,797 [  28269]   INFO - indexing.UnindexedFilesUpdater - Indexable files iterated in 785 ms
2012-01-08 01:52:32,797 [  28269]   INFO - indexing.UnindexedFilesUpdater - Unindexed files update started: 0 files to update
2012-01-08 01:52:32,798 [  28270]   INFO - indexing.UnindexedFilesUpdater - Unindexed files update done in 0 ms
2012-01-08 01:52:33,462 [  28934]   INFO - s.impl.stores.FileBasedStorage - Document was not loaded for $PROJECT_CONFIG_DIR$/templateLanguages.xml file is null
2012-01-08 01:52:33,462 [  28934]   INFO - .impl.stores.XmlElementStorage - Document was not loaded for $PROJECT_CONFIG_DIR$/templateLanguages.xml
2012-01-08 01:52:33,469 [  28941]   INFO - s.impl.stores.FileBasedStorage - Document was not loaded for $OPTIONS$/templateLanguages.xml file is null
2012-01-08 01:52:33,469 [  28941]   INFO - .impl.stores.XmlElementStorage - Document was not loaded for $OPTIONS$/templateLanguages.xml
2012-01-08 01:52:35,947 [  31419]   INFO - #com.intellij.xml.util.XmlUtil - HTML5_SCHEMA_LOCATION = jar:file:\C:\Program Files (x86)\JetBrains\PhpStorm 3.0\lib\webide.jar!\resources\html5-schema\html5.rnc
2012-01-08 01:52:35,947 [  31419]   INFO - #com.intellij.xml.util.XmlUtil - XHTML5_SCHEMA_LOCATION = jar:file:\C:\Program Files (x86)\JetBrains\PhpStorm 3.0\lib\webide.jar!\resources\html5-schema\xhtml5.rnc
2012-01-08 01:52:36,295 [  31767]   INFO - s.impl.stores.FileBasedStorage - Document was not loaded for $PROJECT_CONFIG_DIR$/IntelliLang.xml file is null
2012-01-08 01:52:36,296 [  31768]   INFO - .impl.stores.XmlElementStorage - Document was not loaded for $PROJECT_CONFIG_DIR$/IntelliLang.xml
2012-01-08 01:52:36,404 [  31876]   INFO - s.impl.stores.FileBasedStorage - Document was not loaded for $PROJECT_CONFIG_DIR$/fileColors.xml file is null
2012-01-08 01:52:36,404 [  31876]   INFO - .impl.stores.XmlElementStorage - Document was not loaded for $PROJECT_CONFIG_DIR$/fileColors.xml
2012-01-08 01:52:36,485 [  31957]   INFO - s.impl.stores.FileBasedStorage - Document was not loaded for $PROJECT_CONFIG_DIR$/codeStyleSettings.xml file is null
2012-01-08 01:52:36,485 [  31957]   INFO - .impl.stores.XmlElementStorage - Document was not loaded for $PROJECT_CONFIG_DIR$/codeStyleSettings.xml
2012-01-08 01:52:36,488 [  31960]   INFO - s.impl.stores.FileBasedStorage - Document was not loaded for $PROJECT_CONFIG_DIR$/projectCodeStyle.xml file is null
2012-01-08 01:52:36,488 [  31960]   INFO - .impl.stores.XmlElementStorage - Document was not loaded for $PROJECT_CONFIG_DIR$/projectCodeStyle.xml
2012-01-08 01:52:38,605 [  34077]   INFO - s.impl.stores.FileBasedStorage - Document was not loaded for $PROJECT_CONFIG_DIR$/webResources.xml file is null
2012-01-08 01:52:38,605 [  34077]   INFO - .impl.stores.XmlElementStorage - Document was not loaded for $PROJECT_CONFIG_DIR$/webResources.xml
2012-01-08 01:52:38,970 [  34442]   INFO - tor.impl.FileEditorManagerImpl - Project opening took 13077 ms
2012-01-08 01:52:47,006 [  42478]   INFO - il.connection.ServerConnection - StartingXDebug on port 9000
2012-01-08 01:52:47,016 [  42488]   INFO - il.connection.ServerConnection - StartingZend Debugger on port 10137
2012-01-08 01:52:47,022 [  42494]   INFO - il.connection.ServerConnection - StartingZend Debugger Settings Broadcasting on port 20080
2012-01-08 02:00:24,384 [ 499856]   INFO - api.vfs.impl.local.FileWatcher - 1 paths checked, 0 mapped, 0 mks
2012-01-08 02:00:34,807 [ 510279]   INFO - api.vfs.impl.local.FileWatcher - 2 paths checked, 0 mapped, 0 mks

2012-01-08 02:00:36,045 [ 511517]   INFO - s.impl.stores.FileBasedStorage - Document was not loaded for $APP_CONFIG$/intentionSettings.xml file is null
2012-01-08 02:00:36,045 [ 511517]   INFO - .impl.stores.XmlElementStorage - Document was not loaded for $APP_CONFIG$/intentionSettings.xml



Any further advice will be gratefully received! :)
0
Comment actions Permalink

Hi Joe,

But I have a question about how the incoming Xdebug connection finds its way to my particular PC. There are 3 or 4 different PCs connected to the network (mix of wired/wifi) - but of course, they all share the same public IP address.

How does the Xdebug connection find it's way to my PC, and not any of the others on the same network?

That's what you have to sort out -- you need to use port forwarding (or whatever it may called on your router) to always direct incomming traffic on that particular port (TCP 9000) to a specific IP address inside your home network (in particular, to your desktop PC).

Here is the site that can help you with detailed instructions on how to do it for your particular router: http://portforward.com/english/routers/port_forwarding/routerindex.htm

0
Comment actions Permalink

Ah... (the penny drops...).  I've learned something today... :) - Thank you :)

I've set up the port forwarding, and now PHPStorm is RESPONDING ! woohoo!!

It presented me with a dialog box giving me the chance to accept/refuse the incoming xdebug connection.

I accepted... but now it doesn't appear to be stopping at the breakpoints I have set up.

Is there something else that I need to set up?

(Thanks for your help so far!) :)

0
Comment actions Permalink

Hi Joe,

Because you are doing it for first time in PhpStorm:

  • remove any path mappings (delete the Settings | PHP | Servers) -- PhpStorm will ask you again to set them up during debug (that's in case you have not set them up correctly already)
  • Settings | PHP | Debug --> Xdebug | Break at first line (for external connections) is checked (just in case)


Also -- there are some breakpoints that xdebug is unable to stop at (e.g. multiline array declaration, multiline php statement/function call). Therefore I recommend to start with very simple PHP page, something like that (maybe even on brand new empty project -- just for a first time untill it all sorted):

<?php
$a = 12;
$b = 5;
$x = $a + $b;
echo $x;

Once this is working you can start debugging your real pages.

0
Comment actions Permalink

That's fantastic, Andriy... :)

The breakpoints are working a treat for the simple php code sample.   But for some reason, breakpoints within my Symfony code are not triggering -- I'm not sure why -- but I can investigate that further once I've had some sleep...

THANK YOU THANK YOU THANK YOU for your help!  I *really* appreciate it. :)

0
Comment actions Permalink

Quite likely incomplete/incorrect path mappings.

0
Comment actions Permalink

That's exactly what it was.

Thanks again :)

0
Comment actions Permalink

Andriy,

Thanks for assistance!:)

0

Please sign in to leave a comment.