John Davidson

php - PhpStorm Xdebug remote ssh debugging of CLI script on Vagrant breakpoints not triggering

0 comments
Message:


I am trying to debug a PHP script which is checked out locally on a Windows machine, then mapped to a Ubuntu VM (configured using Vagrant) which have Nginx, PHP and Xdebug installed. Also it's important to point out that I have php-fpm working in this setup and I have had a PHP script running as well, but in VSCode and not PhpStorm.


My PhpStorm config is:



My Xdebug config (currently, I have tried a million different config now):


zend_extension=xdebug.so
xdebug.mode=debug
xdebug.client_host=127.0.0.1
xdebug.client_port=9003
xdebug.remote_enable=1

I then configure my SSH tunnel like so:


putty.exe -ssh <vm-ip> -R 9003:localhost:9003

I am able to run the file and get its output in PhpStorm, but my breakpoints are not working. I just get the following:





And this is the content of the php file I am trying to debug:



So as we can see, the script executes without problem, the breakpoints just don't trigger. And as mentioned I have Xdebug working in PhpStorm for php-fpm when debugging websites, but when trying to debug a single PHP script I run into this problem.


I have tried so many different things, which makes me sure I am overlooking something basic I have forgotten. Right now I am suspecting PhpStorm for being annoying.. on output we can see the script is invoked with:


[vagrant://C:\vagrant]:/usr/bin/php -dxdebug.mode=debug -dxdebug.client_port=9002 -dxdebug.client_host=192.168.1.185

I have not entered these -d arguments anywhere and I am not sure why PhpStorm keeps adding them (also it uses port 9002 and I have configured 9003). But I am not able to get anything working in VSCode as well, so I am properly doing something wrong.


My Xdebug config for php-fpm which is currently working in PhpStorm is:


zend_extension=xdebug.so

xdebug.mode=develop,debug
xdebug.idekey=PHPSTORM

xdebug.output_dir=/tmp/xdebug
xdebug.log=/tmp/xdebug/xdebug.log
xdebug.remote_log=/root/logs/xdebug.log

xdebug.force_display_errors=1
xdebug.force_error_reporting=1

xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_host=127.0.0.1
xdebug.remote_autostart=1

xdebug.client_host=127.0.0.1
xdebug.client_port=9003

xdebug.remote_connect_back=0

xdebug.var_display_max_depth=-1
xdebug.var_display_max_children=-1
xdebug.var_display_max_data=-1

.. i then have a PHP | Servers settings for this as well:



If I try to use this config for PHP CLI script debugging, it's not working either (+ its PhpStorm waiting for Xdebug connections which I guess works a bit differently from PHP CLI script debugging)


What am I doing wrong since my breakpoints are not triggering when running single CLI scripts?



My Answer:
username@hostname -L 9003:127.0.0.1:9003

After setting up the SSH tunnel, I set up a PHP Remote Debug configuration in PhpStorm with the following settings:

- Server: Name of my server
- Host: 127.0.0.1
- Port: 22
- User: username
- Debugger: Xdebug
- Use path mappings: checked
- Path mappings: local path to the PHP script on Windows mapped to the path on the Ubuntu VM

I then set breakpoints in my PHP script and start the debugger in PhpStorm. However, the breakpoints are not triggering and the script runs without stopping at the breakpoints.

I have tried various configurations and settings, but I am unable to get the breakpoints to trigger. Any help or suggestions would be greatly appreciated. Thank you.

Rate this post

3 of 5 based on 2305 votes

Comments




© 2024 Hayatsk.info - Personal Blogs Platform. All Rights Reserved.
Create blog  |  Privacy Policy  |  Terms & Conditions  |  Contact Us