PhpStorm10/xdebug: remote cli script triggers break point but file is not shown

I am using PhpStorm 10 on my local machine and php 5.4/xdebug 2.2.1 on the remote machine.
My project contains a CakePHP based website and some cli scripts.
The cli scripts are in a folder beneath the root folder of the website and are correctly mapped in the server settings.
Based on the fact, that I can easily debug the website (by listening for PHP debug connections and setting a cookie in my requests), I think I configured PhpStorm correctly.
When I execute a cli script on the remote machine, apparently xdebug starts a debug session, PhpStorm opens its debug view and shows the correct file name in the 'Frames' panel with the script stopped at the first line of code (which is not even enabled).
The thing is PhpStorm does not open the corresponding local file. I even can step through the code and watch the variables being changed correctly. Clicking the file name in 'Frames' panel or the 'Show execution point' button does nothing (usually it opens the corresponding local file at the point of execution). When I open the file manually, no execution point is shown.

Has somebody else observed this behaviour? Is this a bug? Or did I do something wrong?

9 comments
Comment actions Permalink

I am having this exact same problem. php script run from the command line triggers PHPStorm debugger. I can step though and get response back from xdebug and watch variables change, but no map back to source code. My PHP Storm logs show this:

2015-11-12 09:44:29,648 [51005013]  DEBUG - .connection.PhpDebugConnection - 880948494#----connection started
2015-11-12 09:44:31,896 [51007261]  DEBUG - p.debug.common.PhpDebugProcess - 1572405220# Stop at ('file:///var/www/html/concrete/bin/concrete5.php':1)
2015-11-12 09:44:31,896 [51007261]  DEBUG - p.debug.common.PhpDebugProcess - 1572405220# remote: 'file:///var/www/html/concrete/bin/concrete5.php' <-> local: '/var/www/html/concrete/bin/concrete5.php'
2015-11-12 09:44:31,896 [51007261]  DEBUG - p.debug.common.PhpDebugProcess - 1572405220# remote: 'file:///var/www/html/concrete/bin/concrete5.php' <-> extracted: '/var/www/html/concrete/bin/concrete5.php'
2015-11-12 09:44:34,880 [51010245]  DEBUG - .connection.PhpDebugConnection - 880948494#---input stream is finished
2015-11-12 09:44:34,880 [51010245]  DEBUG - .connection.PhpDebugConnection - 880948494#---stop writing
2015-11-12 09:44:34,880 [51010245]  DEBUG - .connection.PhpDebugConnection - 880948494#----connection stopped


Notice how it states:

local: '/var/www/html/concrete/bin/concrete5.php

Is this where it is looking for the source code to map to ? I have a remote server set up in PHPStorm and thought I had the files maped correctly, see screen shot. I only have one server set-up, it is a remote server in a docker container. I even went so far as to try and map the individual file.

One more issue is that I have yet to be able to trigger xdebug from the browser using the XDEBUG_SESSION cookie. I can only trigger it via cli. Not sure if this is related, I will create another post about this issue.

Hope this adds to solving your's and my problem.

Thanks,

Warren


Screen Shot 2015-11-12 at 10.09.12 AM.png

0
Comment actions Permalink

I didn't know one can get such detailed output of what's going on :), thank you. I activated debug logs and this came up in my logs.

First for the script started remotely via the built in ssh client:
2015-11-12 19:34:33,573 [ 699731]  DEBUG - .connection.PhpDebugConnection - 7166582#----connection started
2015-11-12 19:34:33,637 [ 699795]  DEBUG - p.debug.common.PhpDebugProcess - 24733334# Stop at ('file:///srv/bvw/app/cliscripts/main.php':2)
2015-11-12 19:34:33,638 [ 699796]  DEBUG - p.debug.common.PhpDebugProcess - 24733334# remote: 'file:///srv/bvw/app/cliscripts/main.php' <-> local: '/srv/bvw/app/cliscripts/main.php'
2015-11-12 19:34:33,638 [ 699796]  DEBUG - p.debug.common.PhpDebugProcess - 24733334# remote: 'file:///srv/bvw/app/cliscripts/main.php' <-> extracted: '/srv/bvw/app/cliscripts/main.php'

This is for an ajax request from the website:
2015-11-12 19:36:19,569 [ 805727]  DEBUG - .connection.PhpDebugConnection - 19794331#----connection started
2015-11-12 19:36:19,831 [ 805989]  DEBUG - p.debug.common.PhpDebugProcess - 5307004# Stop at ('file:///srv/bvw/app/controllers/organisations_controller.php':566)
2015-11-12 19:36:19,831 [ 805989]  DEBUG - p.debug.common.PhpDebugProcess - 5307004# remote: 'file:///srv/bvw/app/controllers/organisations_controller.php' <-> local: 'C:\Users\...\trunk\app\controllers\organisations_controller.php'
2015-11-12 19:36:19,831 [ 805989]  DEBUG - p.debug.common.PhpDebugProcess - 5307004# remote: 'file:///srv/bvw/app/controllers/organisations_controller.php' <-> extracted: '/srv/bvw/app/controllers/organisations_controller.php'

There is clearly something wrong with the internal mapping.

mapping_2.jpg

0
Comment actions Permalink

I am not able to get any farther ahead than the script being executed from the command line. I get no response from xdebug when hitting a page via my browser. At least in your case it looks like it is trying to map when you hit your server. Maybe the debugger doesn't map correctly when a script is run from cli. I think you just need to find out where it is picking up the path:

local: 'C:\Users\...\trunk\app\controllers\organisations_controller.php'

If that is the incorrect path. Maybe you have more than one server defined or you have moved your project on your machine ? I am just guessing.

Thanks,

Warren

0
Comment actions Permalink

Hi there,

with the script stopped at the first line of code (which is not even enabled)

There are 2 options in "Settings/Preferences | Languages & Frameworks | PHP | Debug --> xdebug section" -- they will break at first line if unable to map the script correctly.

It's possible that it is your case.

When I execute a cli script on the remote machine

How do you debug remote script?

Do you initiate debugging from PhpStorm using Remote PHP Interpreter (debugging will be done via SSH connection) .. or you initiate it directly on remote?

If second -- have you configured it (your remote OS/environment) for Remote PHP CLI Scripts debugging? IDE requires some additional steps/configuration to be made in order to debug such stuff.

P.S.

Have you seen these manuals yet?

0
Comment actions Permalink

Hi there,

One more issue is that I have yet to be able to trigger xdebug from the browser using the XDEBUG_SESSION cookie. I can only trigger it via cli.

Linux & Mac (MAMP) quite often have such configuration where CLI and Apache use 2 different php.ini files. Therefore it's possible that xdebug is not configured in one that used to process web requests -- please verify your phpinfo() output.

You can forcibly initiate debug session (assuming everything else is configured correctly, of course):
1) by placing xdebug.remote_autostart = 1 in your php.ini -- this will tell xdebug to debug every single script/request.
2) by placing xdebug_break(); in your code (programmatic breakpoint)

P.S.
Xdebug log may also be usefull

P.P.S.
Have a look at my other answer here -- the part after 2nd quote.

0
Comment actions Permalink

Hi,

you're absolutely right, 'force break at the first line when no path mapping specified' is enabled.

The remote machine has the ip 192.168.1.3 (a turnkey lamp/debian). My development machine has the ip 192.168.1.10 (win 8).
The cli script xdebug config looks like this:
xdebug.remote_enable=1
xdebug.remote_host=192.168.1.10
xdebug.remote_mode=req
xdebug.remote_port=9000

Additionally I added XDEBUG_CONFIG="idekey=debug" to /etc/profile.
You can see the mapping for the remote machine in a post above.

In PhpStorm I start listening for a debug connection. Then on the built in ssh client I connect to the remote machine and start the script by 'php script.php'.

This triggers PhpStorms debugger. It stops at the first line of code, shows me all variables, the correct file name in the 'Frames' panel. But does not open the corresponding local file with execution pointer.

0
Comment actions Permalink

1) Have a look at my last 2 links -- they should help. Right now IDE is unable to do path mapping without that info.
2) Or just initiate debug from PhpStorm using first link  (debugging over SSH; ideally you need to have SFTP deployment created and marked as Default for this project)

0
Comment actions Permalink

Hi,

I followed the instructions and did 'set PHP_IDE_CONFIG=...' on my local machine, while I should have done it on the remote machine. I think the docs should be more clear about this.
XDEBUG_CONFIG and PHP_IDE_CONFIG have to be set on the remote machine for remote cli debugging to work correctly.

Thank you.

0
Comment actions Permalink

You may create a ticket about this on Issue Tracker if you wish.

0

Please sign in to leave a comment.