Debugging console script over vagrant ssh - php

I need to debug a console script run from within my development VM (because of different machine state).
I'm using Netbeans, and I can debug scripts called from the browser just fine.
How do you achieve this, is this possible?
I tried Debugging php-cli scripts with xdebug and netbeans?, but I think this applies only to running the script locally.
My current xdebug configuration:
[XDEBUG]
xdebug.max_nesting_level=200
xdebug.remote_connect_back=1
xdebug.default_enable=1
xdebug.remote_autostart=1
xdebug.remote_enable=1
xdebug.idekey=netbeans-xdebug
xdebug.remote_port=9000
xdebug.remote_handler=dbgp
xdebug.collect_params=4

So, following this https://www.adayinthelifeof.nl/2012/12/20/debugging-remote-cli-with-phpstorm/, I found out that you need to specify the remote host.
Xdebug must know where to send the data to.
I ended up editing my xdebug configuration to look like this:
[XDEBUG]
xdebug.max_nesting_level=200
xdebug.remote_connect_back=1
xdebug.default_enable=1
xdebug.remote_enable=1
xdebug.idekey=netbeans-xdebug
xdebug.remote_port=9000
xdebug.remote_handler=dbgp
xdebug.collect_params=4
xdebug.remote_host=HOST_IP #changed this, removed remote_autostart
So now you just have to turn debugging on in Netbeans and run export XDEBUG_CONFIG="idekey=netbeans-xdebug" in your VM's console.
Next run the script you want to debug.

Related

PHP: Xdebug access denied exit with code 0

I have set the PHP project on Mac with XAMPP and installed Xdebug there, but on my PhpStorm I get:
I did not manage to find anything on the web.
My php.ini
[xdebug]
;zend_extension=xdebug.so
zend_extension=/Applications/XAMPP/xamppfiles/lib/php/extensions/no-debug-non-zts-20190902/xdebug.so
xdebug.remote_enable=1
xdebug.remote_connect_back=0
xdebug.remote_handler=dbgp
xdebug.remote_host=localhost
xdebug.remote_port=9002
xdebug.remote_log="/mnt/log/xdebug.log"
xdebug.remote_autostart=1
xdebug.idekey=phpstorm
xdebug.remote_mode = req
I might be coming late to the party, but make sure XDebug has Write access to the folder, let alone if you're using Docker.
If it's local, then just out of investigation try:
chmod 777 /mnt/log/xdebug.log
However, I'd rather choose to state a folder for the logging over a file.
If it's running within Docker, then "chmod" the actual mounted folder instead.

Xdebug for netbeans and XAMPP not working

I am trying to debug php code using Netbeans but I am unable to, it keeps showing Waiting for connection just like the image below and it stays like that.. I have opned the php.ini and found no xdebug so I added the following lines after installing xdebug and placing it in the path mentioned below.. please let me know what could the issue be .. i am out of ideas ...
[XDebug]
; Note that profiler is enabled separately.
zend_extension="C:\xampp\php\ext\php_xdebug-2.5.0-7.0-vc14-x86_64"
xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_host=127.0.0.1
xdebug.remote_port=9000
xdebug.remote_autostart=0
xdebug.remote_connect_back=0
xdebug.profiler_enable=0
xdebug.profiler_enable_trigger=0
xdebug.profiler_output_name=cachegrind.out.%s.%t
xdebug.profiler_output_dir="C:/WampDeveloper/Temp/xdebug"
xdebug.trace_output_dir="C:/WampDeveloper/Temp/xdebug"

Why xdebug not stop on breakpoint?

I have a problem by xdebug in NetBeans and also PhpStorm!
After running the project in each IDE, in chrome it display this :
but it doesn't stop on any breakpoints!
However in NetBeans when I check Stop on first line of file, it stops on first line and I can debug that file, but again I have problem with break points too.
My php.ini Xdebug :
[XDebug]
zend_extension="C:\wamp\bin\php\php5.5.12\zend_ext\php_xdebug-2.2.5-5.5-vc11-x86_64.dll"
xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_host=127.0.0.1
xdebug.remote_port=9000
xdebug.remote_autostart=0
xdebug.remote_connect_back=0
What's the problem here?

Xdebug installed on Mac Native apache

I am trying to get XDEBUG up and going but having trouble getting the cookie to show. Below is what is put in my php.ini file. I restarted apache. I did a phpinfo() call and I do see xdebug enabled and the settings set. But when I do a localhost/?XDEBUG_SESSION_START=1 I am expecting to see a Cookie set to 1 in my browser right ?
zend_extension ="/usr/lib/php/extensions/no-debug-non-zts-20100525/xdebug.so"
xdebug.remote_enable=1
xdebug.profiler_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.remote_host=127.0.0.1
xdebug.remote_port=9000
xdebug.profiler_output_dir="/tmp"
when I run php -m I do not see it but I do see it in phpinfo
couldnt figure the exact answer but I went and downloaded the php.ini.default file from repo and set the following in the php ini
zend_extension ="/usr/lib/php/extensions/no-debug-non-zts-20100525/xdebug.so"
xdebug.remote_enable=On
xdebug.remote_host=localhost
xdebug.idekey=foo
xdebug.profiler_enable=On
and it worked. could of been because of remote host. who knows. it worked. this is the bare minimum configurations for mac and this is if your going by the follwing installations for xdebug on mac
http://kubyshkin.ru/posts/installing-php-xdebug-extension-on-mac-os-x-10-7-lion.html

Netbeans - XDebug Debugging

I have setup a new dev environment using windows for the first time. I have WAMP installed and I am using netbeans as my IDE and have XDebug installed and reference in my php.ini file.
; XDEBUG Extension
zend_extension = "c:/wamp/bin/php/php5.4.12/zend_ext/php_xdebug-2.2.3-5.4-vc9-x86_64.dll"
which points to my xdebug.dll file.
When I try to debug within netbeans however, it is not stopping on any of my breakpoints. Any ideas of how to get it correctly debug by stopping at my breakpoints? Also just to verify that i am going to the page in question with my firefox browser so its not that I am not running the code
I added the following to my php.ini file and now debugging is stopping on my breakpoints in netbeans
xdebug.remote_autostart=on
xdebug.remote_enable=on
xdebug.remote_enable=1
xdebug.remote_handler="dbgp"
xdebug.remote_host="localhost"
xdebug.remote_port=9000
xdebug.remote_mode=req
xdebug.idekey="netbeans-xdebug"

Categories