1. Install NetBeans PHP version.
It may be necessary to install Java Development Kit to install NetBeans.
2. If you have NetBeans installed check if PHP plugin is included.
- Go to Tools -> Plugins
-
Open Installed tab.
- Check the PHP name of PHP category is in the list.
- If not go Available Plugins tab
- Sort by category and find PHP category and PHP in the “Name” column.
- 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.
6. Press Next and browse for the WordPress site directory or paste its path in the Sources Folder field.
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).
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.
11. Press Ctrl+F5 or Debug -> Debug Project to start debugging.
12. Add watches to calculate variables and functions output during the debug (Ctrl+Shift+F7).
13. To prevent stopping on the first line when debug is starting go to Tools -> Options -> PHP tab and uncheck Stop at First Line.
== 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.
To determine which one you need follow these steps:
- Get PHP information from the server.
-
You need to know the following data:
PHP version Thread Safety Compiler Architecture
-
To manually get this info create a info.php file and paste this code to itÂ
<?php phpinfo() ?>
-
Then copy this file to the server htdocs or www folder and run it from browser. For localhost the URL will be
localhost/info.php
- Find all parameters in the beginning of the page
-
-
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)
- Download the .dll file and put it in the php/ext folder on the server.
-
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.
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.remote_enable=on xdebug.remote_host=127.0.0.1 xdebug.remote_port=9000 xdebug.remote_handler=dbgp xdebug.profiler_enable = 1 xdebug.dump.* 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.