Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to debug JavaScript and PHP together in the same NetBeans (7.3) project?

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.

like image 922
ajmacedo Avatar asked Apr 04 '13 02:04

ajmacedo


1 Answers

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.org/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":

Confirm that Chrome with NetBeans Connector is selected in the dropdown list in the toolbar

(it looks like this in my NetBeans:
NetBeans Connector)

Put some breakpoints before some lines:

JS code breakpoints

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":

"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:

NetBeans JS code debugging; variable


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

  • How do I debug PHP projects? - http://wiki.netbeans.org/HowToDebugPHPProjects
  • Configuring PHP Development Environment in Windows - https://netbeans.org/kb/docs/php/configure-php-environment-windows.html
  • Configuring the PHP Development Environment in Linux Ubuntu - https://netbeans.org/kb/docs/php/configure-php-environment-ubuntu.html
  • Configuring PHP, Apache, MySQL, and Xdebug for PHP development in MAC OS X - https://netbeans.org/kb/docs/php/configure-php-environment-mac-os.html
  • Debugging PHP Source Code in the NetBeans IDE - https://netbeans.org/kb/docs/php/debugging.html
  • How to configure XDebug - http://wiki.netbeans.org/HowToConfigureXDebug
like image 156
Sk8erPeter Avatar answered Sep 20 '22 07:09

Sk8erPeter