I have enabled xdebug in php.ini file as follows:
[XDebug]
zend_extension = "D:\xampp\php\ext\php_xdebug.dll"
xdebug.profiler_append = 0
xdebug.profiler_enable = 1
xdebug.profiler_enable_trigger = 0
xdebug.profiler_output_dir = "D:\xampp\tmp"
xdebug.profiler_output_name = "cachegrind.out.%t-%s"
xdebug.remote_enable = 0
xdebug.remote_handler = "dbgp"
xdebug.remote_host = "localhost"
xdebug.trace_output_dir = "D:\xampp\tmp"
and my netbeans setting is the same as their manual. Now when I try Ctrl+F5 (After setting breakpoint in line 140) then it shows as follows:
How can I see the value of $user_id(or any other variable's value) in netbean's console below??
or Is there are any way available to debug PHP code by setting breakpoint and inspect variable value in CLI like python import pdb;pdb.set_trace()??? so that code break in particular line (When action taken like submit form or reload browser) and then I can inspect each variable before breakpoint even continue after breakpoint
1.Review your php.ini configuration.
xdebug.remote_enable = 1
xdebug.remote_host = localhost
xdebug.remote_port = 9000
Also make sure your zend_extension = "D:\xampp\php\ext\php_xdebug.dll" is correct. On my computer I have / instead of \, not sure if it matters...
2.Restart your server (not sure if needed).
3.Check your netbeans configuration in Tools->options->PHP->Debugging
4.Check you project properties : "Browser" and "Run Configuration"
If everything is correct, you can set a break point within netbeans and laung debug: "Debug"->"Debug project"
Related
I am using Windows 10, NetBeans 11.3, PHP7.4.9, Apache/2.4.46 (Win64), XAMPP v3.2.4 and MySQL.
My php.ini file has the following settings:
output_buffering=off
[XDebug]
zend_extension = "c:\xampp\php\ext\php_xdebug-2.9.7-7.4-vc15-x86_64.dll"
xdebug.remote_autostart = 1
xdebug.profiler_append = 0
xdebug.profiler_enable = 0
xdebug.profiler_enable_trigger = 0
xdebug.profiler_output_dir = "c:\xampp\tmp"
xdebug.remote_enable = 1
xdebug.idekey="netbeans-xdebug"
xdebug.remote_handler = "dbgp"
xdebug.remote_host = "localhost:81"
xdebug.remote_log = "c:\xampp\tmp\xdebug.txt"
xdebug.remote_port = 9000
xdebug.trace_output_dir = "c:\xampp\tmp"
xdebug.remote_cookie_expire_time = 36000
NetBeans configuration:
Debugger port: 9000
Session ID: netbeans-xdebug
Stop at first line: Checked
All other options are unchecked
When I click on debugging icon (Ctrl + F5) it gets stuck on "waiting for connection (netbeans-xdebug)" while shows the page completely without stopping at the break points.
xdebug.remote_host = "localhost:81" is certainly not correct. The remote_host should have the value of the IP address or hostname where your IDE runs. This is likely just localhost.
You should also upgrade to Xdebug 3.1, which has much better logging functionality for troubleshooting connection errors through it's xdebug_info() function, and xdebug.log and xdebug.log_level settings.
Please do refer to the upgrade guide though, as some setting names have changed. You would likely only need:
zend_extension = "c:\xampp\php\ext\php_xdebug-3.1.3-7.4-vc15-x86_64.dll"
xdebug.mode=develop,debug # replacement for xdebug.remote_enable
xdebug.start_with_request=1 # replacement for xdebug.remote_autostart
xdebug.idekey="netbeans-xdebug"
xdebug.client_port = 9000 # replacement for xdebug.remote_port
# I would recommend to use the default 9003,
# but you need to update Netbeans config to
# say the same too.
NetBeans IDE 8.2 (Build 201705191307)
PHP 5.5.38 (due to legacy application)
Chrome 66.0.3359.170 (Official Build) (64-bit)
In the last few days my NetBeans debug stops working after one debug run and will only debug after I restart NetBeans. I've tried disabling all Chrome extensions other than NetBeans Connector and tested if restarting browser and stack would help but only restarting NetBeans works. It will also freeze up in the middle of a debug.
I have not touched php.ini
This is killing my productivity. Has anyone had this problem and how did you fix it?
UPDATE
I set up Visual Studio Code and debugging works fine so this must be a NetBeans issue.
Unchanged php.ini (same settings that worked last week)
[xdebug]
zend_extension = C:\xampp_php_5.5.38\php\ext\php_xdebug-2.4.1-5.5-vc11.dll
xdebug.idekey = netbeans-xdebug
xdebug.profiler_append = 0
xdebug.profiler_enable = 0
xdebug.profiler_enable_trigger = 0
xdebug.profiler_output_dir = "C:/xampp_php_5.5.38/xdebug"
xdebug.profiler_output_name = "cachegrind.out.%t-%s"
xdebug.remote_enable = 1
xdebug.remote_autostart = 0
xdebug.remote_connect_back = 0
xdebug.remote_host = 192.168.1.114
xdebug.remote_port = 9000
xdebug.remote_handler = "dbgp"
xdebug.remote_mode = req
xdebug.trace_output_dir = "C:/xampp_php_5.5.38/tmp"
xdebug.remote_log = "c:/xampp/tmp/xdebug/xdebug_remot.log"
xdebug.show_local_vars = 9
xdebug.trace_output_dir = "C:/xampp_php_5.5.38/tmp"
Derp, I 'fixed' it by removing xdebug.remote_autostart=1 from my xebug.ini file, see nginx php-fpm xdebug netbeans can start only one debug session .
I've created a PHP project in NetBeans called TerraNubis. The project folder and source folder are located in C:\development\TerraNubis. In the Project Properties window, in the Run Configuration tab I've set the option to run the configuration as local website, the project url to http://localhost/TerraNubis/ and the index file to index.php.
I installed XAMPP (xampp-win32-7.1.11-0-VC14-installer.exe on Windows 10) and downloaded Xdebug (php_xdebug-2.5.5-7.1-vc14.dll, which is now located in C:\xampp\php\ext).
The files from the sources folder are being copied to C:\xampp\htdocs\TerraNubis. In the NetBeans Options window I've set the PHP 5 interpreter to C:\xampp\php\php.exe. In the Debugging tab, the debugger port is set to 9000, the session ID to netbeans-xdebug and the maximum data length to 2048. All the checkboxes in this tab are empty.
In my php.ini file I commented out
zend.enable_gc = On
and at the bottom of the file I added the following code:
[XDEBUG]
zend_extension = "C:\xampp\php\ext\php_xdebug-2.5.5-7.1-vc14.dll"
xdebug.idekey = netbeans-xdebug
xdebug.profiler_append = 0
xdebug.profiler_enable = 0
xdebug.profiler_enable_trigger = 0
xdebug.profiler_output_dir = "C:/xampp/tmp/xdebug"
xdebug.profiler_output_name = "cachegrind.out.%t-%s"
xdebug.remote_enable = 1
xdebug.remote_autostart = 0
xdebug.remote_connect_back = 0
xdebug.remote_host = "127.0.0.1"
xdebug.remote_port = 9000
xdebug.remote_handler = "dbgp"
xdebug.remote_mode = req
xdebug.remote_log = "C:/xampp/tmp/xdebug/xdebug_remot.log"
xdebug.show_local_vars = 9
xdebug.trace_output_dir = "C:/xampp/tmp"
In NetBeans, when I right click on the TerraNubis project in the Projects tree and click on Debug, I see at the bottom right the message: "Waiting For Connection (netbeans-xdebug)". Then nothing happens. It just keeps displaying the same message.
How can I run the Xdebug properly on a local website?
I followed this steps, recommended by Xdebug based on phpinfo():
Download php_xdebug-2.4.0rc4-5.6-vc11.dll
Move the downloaded file to C:\xampp\php\ext
Update C:\xampp\php\php.ini and change the line
zend_extension = C:\xampp\php\ext\php_xdebug-2.4.0rc4-5.6-vc11.dll
Restart the web server
I also unchecked the 'ignore external connections through unregistered server configurations in PhpStorm. In PhpStorm port 9000 is configured. This port isn't used by an other application.
In the php.ini file I listed the following configuration:
[XDebug]
zend_extension = C:\xampp\php\ext\php_xdebug-2.4.0rc4-5.6-vc11.dll
xdebug.profiler_append = 0
xdebug.profiler_enable = 1
xdebug.profiler_enable_trigger = 0
xdebug.profiler_output_dir = "C:\xampp\tmp"
xdebug.profiler_output_name = "cachegrind.out.%t-%s"
xdebug.remote_enable = 0
xdebug.remote_handler = "dbgp"
xdebug.remote_host = "localhost"
xdebug.trace_output_dir = "C:\xampp\tmp"
The DLL file exists.
I also enabled the debug functionality in chrome via the xdebug addon.
Which step do I miss?
You're probably going to want to set xdebug.remote_enable = 1 or the remote debugging will be disabled.
Also, set the remote debug port phpStorm is set to use:
xdebug.remote_port=9000 (I'm assuming port 9000, it's the default, but check phpstorm)
To debug every request (if you don't have the chrome plugin for a browser for example) use xdebug.remote_autostart = on
I am debugging a PHP codeigniter project where there is a controller method to read the php://input and get the data from it. I have put a breakpoint in there and it will successfully hit, if I request the method via browser (Which is started by the netbeans debug). I have another JAVA application that sends the data to same method. What I need is to capture that. But netbeans breakpoints does not hit by the requests initiated by the java application. Is there anyway I can achive this ? Thanks in advance.
zend_extension = "C:\xampp\php\ext\php_xdebug.dll"
xdebug.profiler_append = 0
xdebug.profiler_enable = 1
xdebug.profiler_enable_trigger = 0
xdebug.profiler_output_dir = "C:\xampp\tmp"
xdebug.profiler_output_name = "cachegrind.out.%t-%s"
xdebug.remote_enable = 1
xdebug.remote_mode = "req"
xdebug.remote_handler = "dbgp"
xdebug.remote_host = "127.0.0.1"
xdebug.remote_port = 9000
xdebug.trace_output_dir = "C:\xampp\tmp"
After few researches and tweaks I was able to configure this. First you need to add
xdebug.remote_autostart = 1
xdebug.idekey = "netbeans-xdebug"
to php.ini to auto start the debug session without XDEBUG_SESSION_START=netbeans-xdebug and Netbeans only listen to above ide key in default.
Then you should enable Do not open web browser in Project Properties -> Run Configuration -> Advance. No path mapping needed for me (I enabled the option to copy files to server). Now breakpoints should hit request initiated by any source (For me Firefox, Chrome and my Java app).
Reference:
Stackoverflow Question
Xdebug docs