Programming » Wordpress

Debug Site with Netbeans

1. Install NetBeans PHP version.

Debug NetBeans download [sm]

It may be necessary to install Java Development Kit to install NetBeans.

Debug NetBeans JDK download

2. If you have NetBeans installed check if PHP plugin is included.

  1. Go to Tools -> Plugins
  2. Open Installed tab.

    Debug NetBeans plugins

  3. Check the PHP name of PHP category is in the list.
  4. If not go Available Plugins tab
  5. Sort by category and find PHP category and PHP in the “Name” column.
  6. Set checkbox and press Install.

3. Press Ctrl+Shift+N to add new project.

4. Select PHP in Categories.

5. Select PHP Application with Existing Sources in Projects.

Debug NetBeans new project

6. Press Next and browse for the WordPress site directory or paste its path in the Sources Folder field.

Debug NetBeans project source

7. Press Finish or press Next for additional options.

8. After the project is loaded and scanned go to the Projects window (Ctrl+1 if not visible).

Debug NetBeans loaded crop

9. Go to Source Files branch and find a .php file to debug then doubleclick it.

10. Set breakpoints clicking on the line numbers gutter.

Debug NetBeans breakpoint [sm]

11. Press Ctrl+F5 or Debug -> Debug Project to start debugging.

Debug NetBeans debug started [sm]

12. Add watches to calculate variables and functions output during the debug (Ctrl+Shift+F7).

Debug NetBeans add watch

Debug NetBeans watch added [sm]

13. To prevent stopping on the first line when debug is starting go to Tools -> Options -> PHP tab and uncheck Stop at First Line.

Debug NetBeans PHP options

== onProblems ==

Some additional actions may be required if debugging doesn’t work after the above steps.

1. Check the php/ext directory of the server. There should be a file php_xdebug.dll

2. If it doesn’t exist download one from XDebug site.

Debug NetBeans Xdebug download

To determine which one you need follow these steps:

  1. Get PHP information from the server.
    1. You need to know the following data:

      PHP version
      Thread Safety
    2. To manually get this info create a info.php file and paste this code to it 

      <?php phpinfo() ?>
    3. Then copy this file to the server htdocs or www folder and run it from browser. For localhost the URL will be


      Debug NetBeans PHP info

    4. Find all parameters in the beginning of the page
  2. Find the right .dll on the XDebug download page using the obtained information:

    VCx value - get from Compiler parameter (MS VCx)
    XX bit value - from the Architecture (x86 - 32bit, x64 - 64bit)
    TS value - from Thread Safety (enabled - TS, disabled - empty)
  3. Download the .dll file and put it in the php/ext folder on the server.
  4. Use the Xdebug wizard if have some problems. Copy all the info.php page content and paste it in the textarea then press the button under it. You’ll get all the instructions.

    Debug NetBeans Xdebug wizard

3. Edit php.ini file in the php directory. Add this to the end. The zend_extension part contains the path to the downloaded Xdebug .dll file.

zend_extension = "C:/xampp/php/ext/php_xdebug-2.2.7-5.4-vc9.dll"
xdebug.profiler_enable = 1
xdebug.trace_output_dir = "C:\xampp\tmp"

4. Restart the server.

Then go to NetBeans again and press Ctrl+F5. The homepage of the WordPress site should open in the browser and the debugger should stop on breakpoints.

Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>