Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Netbeans and Xdebug in Linux

I have installed Xdebug, and I can confirm from phpinfo() that it is correctly installed. I have taken all the steps given in all of the sites that come up with I google "netbeans xdebug install, etc".

It still does not work in Netbeans. Is there any advice that someone can offer?

Here is my php.ini debug section...

[xdebug]
zend_extension = /usr/lib/php5/20090626/xdebug.so
xdebug.remote_enable = 1
xdebug.remote_mode = "req"
xdebug.remote_handler = dbgp
xdebug.remote_host = 127.0.0.1
xdebug.remote_port = 9000
xdebug.idekey = "netbeans-xdebug"

Any help would be greatly appreciated!

like image 916
aserwin Avatar asked Oct 13 '12 01:10

aserwin


People also ask

How do I enable debugging in Netbeans?

To run a debugging session:Start the ide and open the file that contains the source code that you want to debug. Set a breakpoint at each line where you want the debugger to pause. To set a breakpoint, place the cursor at the beginning of a line and press Ctrl-F8/⌘-F8 or choose Debug > Toggle Line Breakpoint.

How do I debug PHP in Chrome?

Q: How to debug PHP in Chrome? A: You can easily debug PHP in Chrome using a simple extension called PHP Console. Just install this PHP debugging tool from the Chrome web store and start logging errors, warnings, exceptions, and vars dump on your Chrome browser.


2 Answers

Since the information available to me is very sparse, I have to describe the settings in more detail.

Netbeans and xdebug settings.

Ubuntu 12.04 LTS Precise Pangolin

What ought to be installed.

enter image description here

enter image description here

Global settings:

Tools -- Options

enter image description here

enter image description here

PHP settings:

With phpinfo() you get.. see below image.

enter image description here

Only one php.ini is important ! Look at Loaded Configuration File If you wrote a xdebug entry into another "php.ini" file be sure to clear all these entries again. ( xdebug ONLY in one php.ini ). Look also at Additional .ini files parsed. We come to this later.

zend_extension="/usr/lib/php5/20090626+lfs/xdebug.so"
xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.remote_host=localhost
xdebug.remote_port=9000

enter image description here

Additional .ini files parsed.
Add or controlling, only the first line must be the same as in the "php.ini".( Without " " )

enter image description here

Make sure that the file is really there!

enter image description here

Make sure that the session.save_path is really there!

enter image description here

Control the xdebug version that should be equal to or greater.( Matching PHP Version-5.3.10-1 ). If everything was done as described in this answer, and it does not work, then it is with great probability of an incorrect or defective "xdebug.so".

enter image description here

Create a new Php Project:

enter image description here

Project Properties:
Sources
In our test program, it is important the Project Folder and Source Folder are exactly alike!

enter image description here

Run Configuration

enter image description here

enter image description here

Start Debug: -- press Debug button

enter image description here

The default Browser opens and remains at Connecting .. stand while Netbeans in debug mode is.
(If Netbeans do not open a Browser or can not connect, go back to Advanced Web Configuration and select Do Not Open Web Browser. Close an reopen the browser and type the URL as seen below)

enter image description here

Go through your code. You will see only something in the browser when you're done with the debugging. Don't forget to press the Stop Button enter image description here . If you forget this xdebug is running on.

Done:

enter image description here

like image 154
moskito-x Avatar answered Sep 24 '22 02:09

moskito-x


Try using xdebug.remote_connect_back=1 instead of xdebug.remote_host to avoid security issues

In fact,

zend_extension=path/to/xdebug.so
xdebug.remote_enable=1
xdebug.remote_connect_back=1

Must be enough.

Make sure that project properties->run configuration->advanced->do not open web browser option is NOT selected (in netbeans project config).

Also, check project url value in run configuration

like image 28
SlyChan Avatar answered Sep 24 '22 02:09

SlyChan