admin管理员组

文章数量:1405375

In my first steps, I'm using this not rational way, as described below:

  1. Create an HTML5 project to debug the JavaScript code.
  2. Create the definitive PHP project, with JS code already tested, where I debug the server side.

So I'm wondering if there is a smarter way of doing this?
E.g.: create a unique project and switch between native NetBeans JavaScript debugger and the (PHP) XDebug.

In my first steps, I'm using this not rational way, as described below:

  1. Create an HTML5 project to debug the JavaScript code.
  2. Create the definitive PHP project, with JS code already tested, where I debug the server side.

So I'm wondering if there is a smarter way of doing this?
E.g.: create a unique project and switch between native NetBeans JavaScript debugger and the (PHP) XDebug.

Share Improve this question edited Oct 7, 2014 at 13:12 Sk8erPeter 6,9959 gold badges50 silver badges67 bronze badges asked Apr 4, 2013 at 2:23 ajmacedoajmacedo 911 silver badge9 bronze badges 7
  • 1 Why aren't you debugging the JavaScript in the browser? – Matt Ball Commented Apr 4, 2013 at 2:25
  • 1 Agree with @MattBall: you should be debugging JavaScript in the browser. You can use Firebug on Firefox or Chrome Developer Tools in Google Chrome – juan.obando Commented Apr 4, 2013 at 2:32
  • @MattBall, for laziness reasons... of ing back to NetBeans and edit the code, but it is the best way. Thanks for remember. – ajmacedo Commented Apr 4, 2013 at 3:26
  • 1 @MattBall: it can be more fortable to debug AND modify (!) JavaScript code in NetBeans or another favourite IDE of yours. If you are used to write and debug codes in the IDE you configured to your taste (hotkeys, panels, etc.), why not using it? – Sk8erPeter Commented Dec 28, 2013 at 0:57
  • 1 @MattBall: it looks like you've never debugged JavaScript code with NetBeans - it's really simple and worth trying it. Here how to do it quickly: stackoverflow./a/20809988/517705. And the "added plexity" - which means only some minutes of reading+configuring - worth it. This way I can use the IDE I like for debugging and which I have configured, not the browser's inspector which can be a bit more unfortable than the IDE for such tasks. By the way, I admit that the browsers' tools are very smart, I also like and do use them, but like the IDE more for debugging purposes. – Sk8erPeter Commented Dec 28, 2013 at 1:26
 |  Show 2 more ments

1 Answer 1

Reset to default 5

For JavaScript debugging in Chrome, you should use the official NetBeans Connector extension.

Here's an example on how to debug JavaScript code with NetBeans + Chrome + NetBeans Connector:

Debugging and Testing JavaScript in an HTML5 Application https://netbeans/kb/docs/webclient/html5-js-support.html

After creating a new project, you should "Confirm that Chrome with NetBeans Connector is selected in the dropdown list in the toolbar":

(it looks like this in my NetBeans:
)

Put some breakpoints before some lines:

and hit Run. After hitting Run, you will see a yellow warning bar which looks somehow like this, stating ""NetBeans Connector" is debugging this tab":

Do NOT open Chrome's built-in web inspector toolbar now (or you'll get a warning that this breaks the regular debugging process in NetBeans).

Now you can debug JavaScript code in NetBeans, the code will run in Chrome. You should open Window → Debugging → Variables panel to inspect the variables.

Or mouse over some items:


Regarding debugging PHP code, here are some relevant official articles:

  • How do I debug PHP projects? - http://wikibeans/HowToDebugPHPProjects
  • Configuring PHP Development Environment in Windows - https://netbeans/kb/docs/php/configure-php-environment-windows.html
  • Configuring the PHP Development Environment in Linux Ubuntu - https://netbeans/kb/docs/php/configure-php-environment-ubuntu.html
  • Configuring PHP, Apache, MySQL, and Xdebug for PHP development in MAC OS X - https://netbeans/kb/docs/php/configure-php-environment-mac-os.html
  • Debugging PHP Source Code in the NetBeans IDE - https://netbeans/kb/docs/php/debugging.html
  • How to configure XDebug - http://wikibeans/HowToConfigureXDebug

本文标签: How to debug JavaScript and PHP together in the same NetBeans (73) projectStack Overflow