Debugging with xdebug and virtualbox

I'm struggling to get xdebug up and running. I have a ubuntu virtualbox running a lamp stack that I'm using as a local server. I'm able to load the site locally from that. PHPStorm project is set up on a mounted drive that points to /var/www on the local server. 

 

I'm trying to figure out what I need to do in order to get phpstorm to debug. I feel like this is pretty straightforward until I start digging through online tutorials. I feel like I need to set up a CLI Interperter, but I'm not sure which settings to use for that. Any help here would be greatly appreciated. 

1
7 comments

Here's a starting point: https://www.jetbrains.com/phpstorm/documentation/debugging/

You would want to add a CLI interpreter under File | Settings | Languages & Frameworks | PHP that would point to php executable inside a Virtual Box VM

0

I've got the same problem @..., have you managed to sort this out? If yes, care to share the solution?  I've already spent an hour or two researching this, to no avail.

0

You might want to post some screenshots illustrating your current config - we'll be able to assist from there.

0

Thanks mate, I've finally managed to get it running.  There were a number of problems in the end compounding the issue. 

My main source of pain was that a local vbox-instance config isn't really covered clearly anywhere I could find, and quite a number of steps are required.   The online resources are a bit misleading sometimes.   And even when all bits are together it seems you have to kick it into gear with a dummy file in the root of the project - my breakpoint in an included file didn't want to work until I did this.   Took me half a day, sadly.

0

UPDATE: inserting xdebug_break(); in the php helped to stop! Also, xdebug.client_host should point to the machine where IDE is located, not the server.

~~~~

Well, care to tell us what this file is or resources you found.  Now, I have the same or similar issue...  After I hit debug, seems like it connects; there are no errors.  However the exec never stops in PhpStorm wherever I set the breakpoints.  I have the checkboxes to stop at 1st line of php or whenever the source code is not avail. checked.

I'm on XDebug 3, php 7.4

Thank you

D

0

My working configuration (Virtualbox):

zend_extension = /usr/lib64/php/modules/xdebug.so
xdebug.remote_autostart = 1
xdebug.default_enable = 1
xdebug.remote_enable = 1
xdebug.remote_connect_back = 1
xdebug.remote_handler = dbgp
xdebug.overload_var_dump = 1
xdebug.show_exception_trace = 1
xdebug.remote_host = 127.0.0.1
xdebug.remote_port = 9000
xdebug.remote_mode = req
xdebug.idekey = "PHPSTORM"

In PHPSTORM should be configured DBGproxy with IDEKEY: PHPSTORM and port 9000

System: CentOS 7.9, php 7.3, xdebug 2.9.8

0

For anyone finding this answer, please bear in mind that there are significant changes between xdebug 2 and xdebug 3. There is upgrade guide provided by XDebug here: http://xdebug.org/docs/upgrade_guide

My working config now, with phpStorm up to date and VirtualBox:

zend_extension=/usr/lib/php/20170718/xdebug.so 
xdebug.client_host = xxx.xxx.xxx.xxx
xdebug.client_port = 9003
xdebug.mode=debug
xdebug.discover_client_host=true
xdebug.start_with_request=yes

 

zend_extension - should be matched to your php version that you use, mine is php-fpm 7.2

xdebug.client_host - is your local IP, xdebug installation should get this one right

0

Please sign in to leave a comment.