PHPStorm, XDebug, XAMPP, Drupal Remote

Okay so I have XAMPP setup on my windows PC with Drupal installed using bitnami.  I have the trial version of PHPStorm located on my Mac machine where I would like to debug my php code.

I went through setting up XAMPP and XDebug and these are the results from

  • Xdebug installed: 2.2.1
  • Server API: Apache 2.4 Handler Apache Lounge
  • Windows: yes - Compiler: MS VC9 - Architecture: x86
  • Zend Server: no
  • PHP Version: 5.4.7
  • Zend API nr: 220100525
  • PHP API nr: 20100525
  • Debug Build: no
  • Thread Safe Build: yes
  • Configuration File Path: C:\WINDOWS
  • Configuration File: C:\xampp\php\php.ini
  • Extensions directory: C:\xampp\php\ext
  • You're already running the latest Xdebug version

    Looks like it's installed.

    I added a PHP Web Application in Run/Debug Configuration with my server information and Server.

    I hit the phone icon, and attempt to put a break point somewhere within a module I'm working on in Drupal.  I navigate to the page when the browser opens and it doesn't break.

    Comment actions Permalink

    I would like to add that when I try to access my XAMPP main web page at http://XAMPP-SERVER-IP/xampp/ PHPStorm decides to break on the index.php for an unexplained reason.

    It says "Remote file path 'C:\xampp\htdocs\xampp\index.php\ is not mapped to any file path in the project"

    So I'm assuming PHPStorm connects to XDebug just fine but it's not working correctly with the drupal side of things.

    If I get this working I'm definiately buying phpstorm since I'm coming from Coda 2 that has no debugging but I can't get the debugging to work.

    Any help is appreciated.

    Comment actions Permalink

    Hi there,

    And how did you configured your xdebug ? (please show settings from php.ini as well as corresponding output from phpinfo(); )

    Useful links (if followed correctly, it is enough to make it working):

    It says "Remote file path 'C:\xampp\htdocs\xampp\index.php\ is not mapped to any file path in the project"

    Have you configured path mappings (Preferences | PHP | Servers) ?

    In any case: please provide more info about your configuration (screenshots)

    Comment actions Permalink

    I will take a look at the links and provide screenshots of my configuration.

    This is my php.ini file

    zend_extension = "C:\xampp\php\ext\php_xdebug.dll"
    xdebug.profiler_append = 0
    xdebug.profiler_enable = 1
    xdebug.profiler_enable_trigger = 1
    xdebug.profiler_output_dir = "C:\xampp\tmp"
    xdebug.profiler_output_name = "cachegrind.out.%t-%s"
    xdebug.remote_enable = 1
    xdebug.remote_handler = "dbgp"
    xdebug.remote_host = ""
    xdebug.trace_output_dir = "C:\xampp\tmp"
    xdebug.idekey = "16065"


    xdebug support enabled
    Version 2.2.1
    IDE Key 16065

    Supported protocols Revision
    DBGp - Common DeBuGger Protocol $Revision: 1.145 $

    Directive Local Value Master Value
    xdebug.auto_trace Off Off
    xdebug.cli_color 0 0
    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.coverage_enable On On
    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 16065 16065
    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 On On
    xdebug.profiler_enable_trigger On On
    xdebug.profiler_output_dir C:\xampp\tmp C:\xampp\tmp
    xdebug.profiler_output_name cachegrind.out.%t-%s cachegrind.out.%t-%s
    xdebug.remote_autostart On On
    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_log no value no value
    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_enable_trigger Off Off
    xdebug.trace_format 0 0
    xdebug.trace_options 0 0
    xdebug.trace_output_dir C:\xampp\tmp C:\xampp\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
    Comment actions Permalink

    I attached a few screenshots.  I think that's everything.

    Screen Shot 2013-06-19 at 11.51.49 AM.png
    Screen Shot 2013-06-19 at 11.52.21 AM.png
    Comment actions Permalink

    As I understand is IP of your Mac. If so -- xdebug seems to be configured correct (just by looking at the values)

    I would like to add that when I try to access my XAMPP main web page at http://XAMPP-SERVER-IP/xampp/ PHPStorm decides to break on the index.php for an unexplained reason.

    It says "Remote file path 'C:\xampp\htdocs\xampp\index.php\ is not mapped to any file path in the project"

    You have xdebug.remote_autostart=1 -- so no surprises here -- xdebug will attempt to debug EVERY single page, even if it is belongs to completely different website. This option means that you do not need to use any bookmarklet/browser extension/query param to init session -- all what you need is to activate that "phone handle" icon.

    You can prevent PhpStorm from reacting to such requests (when file is outside of the project) -- check "Preferences | PHP | Debug", it has few options there. But do it only after you will actually make debugging to work.

    Now .. back to the subject:

    1. if you have not configured anything yet at "Preferences | PHP | Servers" (no entries there at all), then just leave as is. What you need in such case: 1) navigate to the page you want to debug; 2) activate "phone handle"; 3) refresh the page.  IDE should receive debug request .. and because you have nothing configured yet at "PHP | Servers" .. it will prompt to set it up (and will help you in this) -- just choose correct file path and (depending on other factors) you should be ready to debug
    2. if you already have it configured .. then quite likely you have not done it properly (quite often the reason -- especially if you just start using this product). You need to specify correct path mappings between your Mac (project path as PhpStrm sees it) and remote Windows (as seen from xdebug point of view). Xdebug point of view is the KEY here .. as xdebug works with resolved/final path ONLY .. and if you have symbolic links .. they will be derefferenced. that's why it's important to provide final/resolved path there (IDE is very helpful here with that popup .. but it only works for initial script -- any subfolders/other locations you will have to add manually, hence the "other factors" in previous paragraph). NOTE: You can delete such entry .. and let PhpStorm help you here (so it becomes #1)
    Comment actions Permalink

    I removed the PHP->Servers so I could recieve the prompt for configuring it when I go to the page.  It does pop up but the file I'm trying to debug is not index.php, it's logo_management.module and I can't seem to select it.

    Screen Shot 2013-06-19 at 12.26.57 PM.png
    Comment actions Permalink

    Well .. I do not know all the details (how Drupal works .. and where modules are located etc) .. but I believe (strongly believe) that the file PhpStorm offers is actually correct and you should accept this mapping. As far as I'm aware URL rewriting is in use .. so the details quite likely to be correct as all requests should go trough single entry point: index.php (and then inside it's routed further).

    On your previous screenshot (the opne that has mappings set manually) you have set the remote root folder to be c:\xamp\apps\drupal\htdocs
    Here IDE tells us that file that currently is debugged is c:\xamp\apps\drupal\htdocs\index.php (same folder as above)

    If you accept such mapping -- what would happen? Will it work .. or will IDE ask for another mapping etc?

    BTW -- have you ever renamed any folder in this path: /Users/Rich/PhpstormProjects/Logo Rally ?? (for example: "logo rally" --> "Logo Rally")

    Comment actions Permalink

    I accepted the mapping and the breakpoint doesn't work within the module file.  It doesn't work anywhere else but having a breakpoint in the index.php file works which is only about 10 lines of code so it doesn't help much.  I never renamed the folder.  

    I appreciate the help I've been trying to get this working since last night!

    Comment actions Permalink

    OK .. breakpoint in another file does not work.

    1) What kind of line it is? A screenshot please. Thing is -- xdebug cannot stop on certain breakpoints (e.g multiline statements or other weird things)

    2) Will it work if you invoke breakpoint manually (e.g. by placing xdebug_break(); line in such file) ?

    3) Does IDE able to step in into that file (e.g. breakpoint is hit in index.php .. and then you proceed line by line and step into other files) ?

    4) That "module file" -- what is the full path on the remote server (resolved path, in case of symlinks) ?

    5) If nothing -- please collect some detailed logs:

    Comment actions Permalink

    I put a breakpoint at a initialization of an array just to see if things work.

    I also tried putting in xdebug_break and it's not causing any errors or a break for that matter.

    Screen Shot 2013-06-19 at 2.40.50 PM.png
    Comment actions Permalink

    So .. what about other points?

    The breakpoint icon (in this module file) -- how does it look when you debug index.php? Does it look like plain red circle .. or is it like in index.php (red circle with a tick inside)?

    If second (with the tick) -- breakpoint is successfully registered and it should work; if not -- most likely path mapping issue (or MacOS-specific "nuance" (remember, I've asked if you renamed any of such folders -- there is a nuance about that and PhpStorm does not play well in such case)) -- logs are definitely required here as only they can tell what paths got used by both sides.

    Request that module DIRECTLY (e.g. (or better -- any other .php file in that folder -- add some with .php extension and request it) ).

    • Delete existing entry in "PHP | Servers"
    • Create some simple php file there (in folder where module is located)
    • Activate "phone handle" if not yet activated
    • Put breakpoint in that file
    • Request it (but make sure that no URL rewrite will interfere)
    • See what path will be offered/detected by IDE

    The reason -- maybe (just maybe) the path on the server will be quite different to what you are expecting it to be.

    Comment actions Permalink

    I just wanted to say thank you for all of the help that you have provided.  Everything is working fine now, and it wasn't anything to do with phpstorm. :_|  Drupal's cache needed refreshing  in order for hooks to work.

    In the end I appreciate all of the help you gave me and now it's time to code with phpstorm!


    Please sign in to leave a comment.