Attaching Netbeans to XDebug on XAMPP Webservice fails - php

I would like to debug a webservice which is called from my C#/.Net Application using XAMPP 1.8.1 and Netbeans 7.3.
Whereas the integrated debugging works fine with Netbeans I can't attach the debugger manually to intercept the calls to the webservice functions.
I'm not exactly sure how the correct usage is. The main problem seems to be that xdebug is simply not yet running when trying to attach the debugger. I have no clue at the moment how to achieve this correctly, when an external application accesses the webservice.
I've tried to fire a previous "..php?XDEBUG_SESSION_START=netbeans-xdebug" call to the local xampp server, but it didn't helped or it was uncorrectly done.
How do I correctly set up a running xdebug session with my app so I can attach the Netbeans debugger correctly and can then debug the single webservice calls ?

OK,
got it based on this solution: Using XDebug to trace a PHP web service page:
Below is the php.ini configuration used with xampp:
[XDebug]
zend_extension = "\xampp\php\ext\php_xdebug.dll"
xdebug.profiler_append = 0
xdebug.profiler_enable = 1
xdebug.profiler_enable_trigger = 0
xdebug.profiler_output_dir = "\xampp\tmp"
xdebug.profiler_output_name = "cachegrind.out.%t-%s"
xdebug.remote_enable =1
xdebug.remote_handler ="dbgp"
xdebug.remote_port=9000
xdebug.remote_host ="localhost"
xdebug.trace_output_dir = "\xampp\tmp"
Start Netbeans Debugging, so that the entry page is stopped at the first line
Start your webservice request with an attached "./service.php?XDEBUG_SESSION_START=netbeans-xdebug"
Continue execution in Netbeans
Execution should stop on the webservice breakpoint.
This should work as long as normal xdebug function is properly configured in the netbeans IDE. Tested with XAMPP 1.8.1 on Win7 x64.

Related

How to debug Laravel application using PhpStorm

I'm developing a Laravel 8.6 application using PHP 8.1 with Xdebug extension but I can't get the PhpStorm's debugging tool to work.
Here's my debug configuration. Notice that I'm using a virtual host
PhpStorm's is listening for PHP debug connections and I set a breakpoint to an endpoint but when I make the http request via Postman nothing happens. What am I doing wrong?
php.ini
zend_extension=C:\xampp\php\ext\php_xdebug.dll
xdebug.mode=debug
xdebug.remote_enable = 1
xdebug.remote_host = "api-fitplanner.localhost"
xdebug.remote_autostart=on
xdebug.remote_enable=on
xdebug.remote_port=9003
You are using Xdebug 2 settings, but you are running Xdebug 3.1.3. Please refer to the upgrade guide on how to convert these.
From what you wrote above, it should be:
zend_extension=C:\xampp\php\ext\php_xdebug.dll
xdebug.mode=develop,debug
xdebug.client_host="api-fitplanner.localhost"
xdebug.start_with_request=yes

Xdebug not breaking on breakpoints after new HD

The problem:
I can not get xdebug to work with PhpStorm or NetBeans in localhost. I have the proper Xdebug ext installed based on the wizard. I can see Xdebug is installed properly from phpinfo() and php -v output. I got a new hard drive at work with a new OS install and ever since then I can't get Xdebug setup to work.
I can not get the breakpoints to hit when accessing the application through the web/Postman. It's like the breakpoints aren't there or no connection is detected. There is no log file generated.
What does work:
In PhpStorm I hit the debug phpunit.xml icon then it runs my PHPUnit tests and Xdebug does work, breakpoints are hit, and log files are generated.
I have tried:
Many versions of Xdebug including 2.55, 2.60, 2.61 both 64 and 32 bit and both thread safe and non thread safe
Hosting with php -S and with XAMPP Apache
NetBeans and PhpStorm
My php.ini xdebug section
[Xdebug]
zend_extension=C:\xampp7.1\php\ext\php_xdebug-2.6.1-7.1-vc14.dll
xdebug.remote_enable=1
xdebug.var_display_max_depth = -1
xdebug.var_display_max_children = -1
xdebug.var_display_max_data = -1
xdebug.remote_host=127.0.0.1
xdebug.remote_port=9000
xdebug.remote_log=C:\xampp7.1\php\ext\xdebug.log
xdebug.idekey="PHPSTORM"
I don't know what else to try. I thought maybe it could be a company firewall issue or something but none of my coworkers have this issue nor did I before the new HD. I'm on Windows 10 Enterprise could it be some Windows configuration?
Credit to LazyOne for figuring out the solution!
Adding xdebug.remote_autostart=1 to the php.ini worked! Thanks so much

Debug menu disabled in Netbeans 8.0.2 when using Wampserver 3.1.1 and preinstalled Xdebug

I'm trying to debug a PHP project for class, and when I try to set a breakpoint in Netbeans, nothing happens. If I go to the Debug menu, everything's grayed out except Attach Debugger, Stack (though everything in that submenu is grayed), New Breakpoint, and New Watch. However, if I try to set a breakpoint through the Debug menu...nothing.
I have looked at (and tried) just about every solution on StackOverflow related to Netbeans, Xdebug, and WAMP. This includes changing the php.ini file, changing the configuration settings in the project in Netbeans, changing the Debugging options in the PHP area of the Netbeans options menu. I have even tried installing a second Xdebug, but still nothing. There was one question in the past with this issue, and the OP updated his Netbeans to a more recent version and that fixed the problem, but I have the latest version already.
I've also looked at the NetBeans site and forums, Wampserver site and forums, and general Google searches for this issue. I finally gave up and I'm turning to the StackOverflow collective intelligence.
My installations:
Windows 10 64-bit
Netbeans 8.0.2
Wampserver 3.1.1
PHP 5.6.18 (though I tried switching to PHP 7.0 and the problem persisted)
My server configuration shows that Xdebug is installed, and phpinfo() also shows it.
My code in php.ini:
[xdebug]
zend_extension ="C:/wamp/bin/php/php5.6.18/zend_ext/php_xdebug-2.4.0rc2-5.6-vc11-x86_64.dll"
xdebug.remote_enable = on
xdebug.profiler_enable = on
xdebug.profiler_enable_trigger = off
xdebug.profiler_output_name = cachegrind.out.%t.%p
xdebug.profiler_output_dir ="C:/wamp/tmp"
xdebug.show_local_vars=0
xdebug.remote_handler=dbgp
xdebug.remote_host=localhost
xdebug.remote_port=9000

Xdebug suddenly not properly working on Eclipse Neon PHP Ubuntu 16

It was working properly yesterday, all I did today was installing docker, which shouldn't have anything to do with it.
The situation is that I can start debugging, but when I hit any of the "Step" (F5, F6, F7, F8) buttons it will say "PHP Applications (Waiting...)" as if it was executing code, but it will never end.
If I disable "Break at First Line" it will even go to the breakpoint, and I can evaluate any variable previous to the breakpoint, but it won't continue.
I've tried creating new projects, reinstalling xdebug and php, switching the port, uninstalling docker just in case, changing xdebug parameters in php.ini.
The thing is that the debugger works, but only until the first breakpoint.
php.ini:
zend_extension=/usr/lib/php/20151012/xdebug.so
xdebug.profiler_output_dir="/tmp/xdebug/"
xdebug.profiler_enable=off
xdebug.profiler_enable_trigger = off
xdebug.remote_enable=on
xdebug.remote_host="localhost"
xdebug.remote_port=9000
xdebug.remote_handler="dbgp"
xdebug.idekey=ECLIPSE_DBGP
xdebug.remote_connect_back=1
xdebug.show_local_vars=0
xdebug.max_nesting_level=400
Some of the variables I added for testing, with no success.
phpinfo()
Finally I had some time to play with configurations, after reinstalling xdebug for php7, trying different rules in /etc/php/7.0/cli/conf.d/20-xdebug.ini, I read in a github project issues thread:
I solved by remove all Watch Variables.
And I thought, "it cannot be that", but gave it a chance, and it did it. Maybe playing with the .ini file helped, but what made it work at last was removing all the expressions in eclipse debug window.
Here is the git issue thread (the project is a PHP Debug Adapter for Visual Studio that has nothing to do with my environment): https://github.com/felixfbecker/vscode-php-debug/issues/205
Anyway here is the 20-xdebug.ini configuration that is working for me:
zend_extension="/usr/lib/php/20160303/xdebug.so"
xdebug.remote_autostart=on
xdebug.remote_enable = On
xdebug.remote_port = 9000
xdebug.remote_host = 127.0.0.1
xdebug.show_error_trace = 1
xdebug.remote_handler="dbgp"

Netbeans xDebug only runs once on Mac

I'm running Netbeans on my Mac. I installed my local server using XAMPP and have installed xDebug. When I go to debug/breakpoint in Netbeans, I can get it to run the first time on index. However, after the first run it won't attach to xDebug again unless I restart Netbeans.
How can I make sure that Netbeans always attaches to xDebug? Also, how do I get Netbeans to debug something besides the index file?
In your php.ini add following
; XDEBUG Extension
zend_extension = "**ABSOLUTE_PATH_TO_XDEBUG_EXTENSION**"
[xdebug]
xdebug.remote_enable = off
xdebug.profiler_enable = off
xdebug.profiler_enable_trigger = off
xdebug.profiler_output_name = cachegrind.out.%t.%p
xdebug.profiler_output_dir = "**PATH_TO_TMP_DIRECTORY**"
In NetBeans IDE go to Tools > Preferences > PHP > Debugging
Debugger Port: 9000
Session ID: netbeans-xdebug
CHECK : Stop at First Line
Open your project. Go to Project Properties > Run Configuration. Set
Run As: Local Web Site (running on local web server)
Project URL: http://localhost/PROJECT_PATH/
Index File: index.php
Save your project file
Restart Apache
Restart NetBeans, open project, then
Debug > Debug Project
You should see http://localhost/PROJECT_PATH/index.php?XDEBUG_SESSION_START=netbeans-xdebug in the browser and NetBeans should stop at the first line of index.php
Might be problem with incompatible version of xdebug. For example downgrading xdebug from 2.2.4 to 2.2.3 solves the problem. http://bugs.xdebug.org/view.php?id=1038
Try deleting all files on your tmp dir set on xdebug.profiler_output_dir
I had a similar situation where xdebug would work only "once" - on the first page load. After I emptied the tmp folder it worked ok.

Categories