more remote debugging from the CLI

I may have spoken too quickly about debugging working from the CLI.

It connects and stops on the first line, but then I can't step or hit breakpoints.
I thought I did when I first tried it, but I may have just seen it stop at the first line.

Also, we have two processes hitting the PHP code in PHPStorm at the same time.
One is the backend, the other is the unit tests hitting the API from a separate
process.  Both in the same project.  Is that going to be a problem?
Can the listen pick up on both connections?

Log files attached.

Thanks,
Brad.



Attachment(s):
xdebug.remote_log.txt.zip
idea.log.zip
6 comments
Comment actions Permalink

Hi Brad,

Remote CLI debugging:


Accordingly to idea.log PhpStorm also tries to debug phpunit (/usr/bin/phpunit) command itself (which is a normal PHP file) which you do not have you your Windows PC (at least not on that path). Possibly that is the reason (sorry, cannot be more specific without actually seeing what is really happening there). You need:

  • either setup PhpStorm to ignore debug requests for files outside of your project (Settings | PHP | Debug | Force break at first line when a script is outside of the project)
  • or make sure that such external file(s) is linked to your project (e.g. add it to the project by copying the actual file somewhere inside project .. or maybe add it as separate Content Root in Settings | Directories) and paths are mapped in (Settings | PHP | Servers)


Try again after making the aforementioned changes.

Also, we have two processes hitting the PHP code in PHPStorm at the same time.
One is the backend, the other is the unit tests hitting the API from a separate
process.  Both in the same project.  Is that going to be a problem?
Can the listen pick up on both connections?

Not sure (really) if it can handle 2 simultaneous debug sessions (when 1 request is not yet finished debugging (e.g. paused on breakpoint) and another one initiated). AFAIR it was working like that in v2 or so .. but I think later it was disabled as it was causing problems/confusions for users when site was using frequent ajax requests (too many debug sessions one after another). Don't know current status of this feature since I had no need in such functionality myself yet. You really have to try it yourself.

0
Comment actions Permalink

Progress.

I had tried removing the settings from my command script in the hopes
that it woud use the ones in htaccess, but of course that didn't work.

The settings are back in there and it does connect.

export XDEBUG_CONFIG="idekey=PHPSTORM remote_host=bwhite remote_enable=1"
export PHP_IDE_CONFIG="serverName=hqdev01"


I turned off both "break on first line" setttings and that helped.
Now it is actually stopping at the first breakpoint.

I can see the call stack and local variables.   This by itself will be huge.

Next I'd like to be able to step through the code.  It only stops at the
first breakpoint, nothing after that. Steps, xdebug_break, and breakpoints
are all ignored.

Logs attached.

Thanks,
Brad.


Attachment(s):
script_being_run_from_server.zip
xdebug.remote_log.txt.zip
idea.log.zip
0
Comment actions Permalink

I had tried removing the settings from my command script in the hopes
that it woud use the ones in htaccess, but of course that didn't work.

Well -- CLI mode has nothing to do with .htaccess (but should work with user .ini files (user_ini.filename) -- try investigating it once more -- I think the value here must be set in actual php.ini, as they are searched before script will actually be executed).

I turned off both "break on first line" setttings and that helped.
Now it is actually stopping at the first breakpoint.

Good. This means that PhpStorm now skips all non-project/external files (like /user/bin/phpunit etc)

It only stops at the first breakpoint, nothing after that. Steps, xdebug_break, and breakpoints are all ignored.

I'm not a PhpStorm dev to tell you what exactly should be in the log and what exactly can be wrong here, so I will just ask/suggest:

1) Does simple script debugs fine? By simple script I mean the one that has NO dependencies on non-native php functions (not a PHPUnit test or anything like that) and uses
ONLY php-native functions; can be a bit complex, can rely on other simple/basic files in project.

2) If above works -- then maybe it's a path mapping/missing file issue again? Do you use symlinks in your project? As far as I understand the logs all breakpoints were set on files within a project, but if symbolic links are involved, then those paths could be different (xdebug works with final/resolved paths only). Can you show screeshot of your problematic file, show where debugger/breakpoint works and where it stop working?

But once again -- I'm not a PhpStorm dev to tell you what exactly is going wrong -- maybe the actual responsible developer will notice this thread and will be able to help you further, because I don't have any other solid ideas about what else can be wrong sitting here while you and your environment is overthere (it also could be a bug in xdebug or PhpStorm itself).

0
Comment actions Permalink

> 1) Does simple script debugs fine? By simple script I mean the one that has NO dependencies
> on non-native php functions (not a PHPUnit test or anything like that) and uses
> ONLY php-native functions; can be a bit complex, can rely on other simple/basic files in project.



I don't know how to execute anything from the CLI besides phpunit.

Do you have any suggestions on how to do this?
For example, can I somehow execute our previous test function from the CLI?

Thanks,
Brad.
0
Comment actions Permalink

> 2) If above works -- then maybe it's a path mapping/missing file issue again? Do you use symlinks in your project?

No symlinks, but the IDE is on my machine, the code is executing on the server,
and the paths are slightly different.  But they look like they are mapped correctly.

Thanks,
Brad.

0
Comment actions Permalink

> 1) Does simple script debugs fine? By simple script I mean the one that has NO dependencies
> on non-native php functions (not a PHPUnit test or anything like that) and uses
> ONLY php-native functions; can be a bit complex, can rely on other simple/basic files in project.

I don't know how to execute anything from the CLI besides phpunit.

Do you have any suggestions on how to do this?
For example, can I somehow execute our previous test function from the CLI?

I'm not a Linux guy, so cannot be sure about paths, but it would be something like that:

/usr/bin/php -f <file_name_to_execute>
0

Please sign in to leave a comment.