Set Up DBGP PHP Debugging for NotePadd++

I have ventured into the wonderful world of enterprise PHP development at work. This is a big change from ASP.net and a lot of work to get up to speed. I thought I’d share my adventure in setting up debugging for a tool in my dev environment, NotePad++. An added plus after running through this exercise was that debugging was also working in Netbeans.

If you already have xdebug installed and configured on your server, you can probably skip to step 7. If you installed an IDE that uses Zend, like Aptana, that already has an xdebug pluggin, you may already have xdebug installed and configured on your server. If you are unsure you can search you php.ini file for zend_extension and see if you have settings similar to step 4.

1.       Get a copy of your phpInfo(). Create a new php page and enter:

<?php

phpinfo();

?>
View the page in the browser and copy everything on this page so you can paste in next step.

2.       Go to http://www.xdebug.org/find-binary.php

3.       Paste the text you copied from step 1.

4.       Click the button and follow the directions to install xdebugg. Add the following config key ([xdebug]) and settings to your php.ini file (mine is here, C:/www/xampp/php/php.ini, but yours may be somewhere else), updating the path to match your machine (create tmp/xdebug/ folder if you don’t have one):

[xdebug]

zend_extension=”C:/www/xampp/php/ext/php_xdebug.dll”

xdebug.profiler_output_dir = “C:/www/xampp/tmp/xdebug”

xdebug.remote_log=”C:/www/xampp/tmp/xdebug/xdebug_remot.log”

xdebug.profiler_output_name = “cachegrind.out.%p”

xdebug.profiler_enable = 0

xdebug.profiler_append=0

xdebug.extended_info=1

xdebug.remote_enable=1

xdebug.remote_handler=dbgp

xdebug.remote_mode=req

xdebug.remote_host=127.0.0.1

xdebug.remote_port=9000

xdebug.idekey=xdebug

xdebug.show_exception_trace=0

xdebug.show_local_vars=9

xdebug.show_mem_delta=0

xdebug.trace_format=0

5.       Restart PHP.

6.       Download the DBGP plugin: http://sourceforge.net/projects/npp-plugins/files/DBGP%20Plugin/

7.       Unzip and move dbgpPlugin.dll to your Notepad++ plugins folder (C:\Program Files\Notepad++\plugins).

8.       Restart Notepad++ and you should see DBGP in your plugins menu.

9.       In you menu click Plugins > DBGP > Config… and check “Bypass all mapping (local window setup). If you need remote debugging you can configure that, but I didn’t do that yet so I won’t act like I did.

10.   From here you can add your break points by clicking on a line and hitting the red circle in the debug window. To start debugging just add “?XDEBUG_SESSION_START=name” with name being anything you like. Now the Notepadd++ debug window should have activated and you can step through the code. If not, something is wrong and you may have to Google better or more recent instructions.

If you use Firefox, there is a xdebug Firefox Extension, https://addons.mozilla.org/en-US/firefox/tag/xdebug. When my debugger is started I don’t have to use the query string to start debugging in the browser, just open the page and it starts. I haven’t tested these, but there are other browser helpers too:

The configuration in step 5 will also works with debugging in NetBeans if you use that IDE. I didn’t test with anything else.

More info:

Xdebug Docs: http://www.xdebug.org/docs/

DBGP Support Forum: http://sourceforge.net/projects/npp-plugins/forums/forum/709026

Leave a Reply

    RSS Subscribe to comment feed.