ehviewer 1.0.24.apk:How to Setup BDGp debugger in Notepad to De...

来源:百度文库 编辑:中财网 时间:2024/04/30 09:12:31

How to Setup BDGp debugger in Notepad++ to Debug PHP

March 27th, 2010 | Category: Computer, PHP, Program Language

Introduction

This article only covers the processes to install Notepad++ and Notepad++ DBGp plugin debugger for debugging PHP scripts.

How does the DBGp Plugin work

The web browser requests url through the http port (80) to the Apache server.
XDebug is an Apache extension (dll), like GD2 graphic library or so…
XDebug is an interface betweeen the server (Apache) and a remote debugging client (DBGp Plugin), they communicate through another port (9000).

Web browser <==> Port 80 <==> Apache + PHP + Xdebug extension <==> Port 9000 <==> DBGp Plugin-notepad++

  1. Notepad++ is started, DBGpplugin opens socket 9000
  2. Web browser requests a PHP page from Apache server. This request includes in the url a specific parameter to start remote debugging (XDEBUG_SESSION_START).
  3. Web server (Apache) fires up the PHP interpreter
  4. PHP interpreter loads XDebug module.
  5. XDebug module detects the specific parameter and starts remote debugging…
  6. XDebug connects to the “remote” debugging client (depending on xdebug configuration)
  7. XDebug and debug client are connected, with user interaction, commands and data are sent over the debugging port (9000)
  8. When debug client instructs XDebug to execute one or more php statements, PHP code is executed and possible output is sent over http Port (80) to web browser.
  9. When all instruction of php are executed, XDdebug disconnects from client.
  10. Apache closes connection to browser.

Installation steps

You should install Apache and PHP on your own (WinLamp is a good package for Windows, but there others like Xampp, you can also install Apache + PHP without a ‘package’…). For reference purpose, my PHP module is in the C:\WebServer\Apache2\modules\php directory (it may be different with others Apache + PHP packages).

1. Download the npp.X.Y.Installer.exe (V4.3 or higher) to your hard drive.

2. Double click the npp.X.Y.Installer.exe on your hard drive to install Notepad++ onto your computer. The default installation directory is C:\Program Files\Notepad++\.

3. Download DBGP plugin to your computer. It is a zipped file.

6.Unzip the file and move the dbgpPlugin.dll and README.txt to C:\Program Files\Notepad++\plugins. Be sure to read the Readme.txt for the latest information.

7. Create a php file name phpinfo.php with the following lines in it:

8. Load the phpinfo.php in your server. For me, that is: http://localhost/supplier/phpinfo.php. Check the php version number at the top of the page. My PHP is version 5.1.4 Also pay attention to your php.ini location. My php.ini is at: C:\WebServer\Apache2\modules\php\. Also look for your php extension directory under the Configuration – PHP Core section (you can search extension_dir). For my php, it is: C:\WebServer\Apache2\modules\php\ext\.

9. Go to http://www.xdebug.org/ to download the Xdebug Windows module for your PHP version. For me, that is PHP 5.1.2 – 5.1.6. The file is php_xdebug-2.0.0-5.1.6.dll.
10. Move the php_xdebug-2.0.0-5.1.6.dll to your php extensions directory (C:\WebServer\Apache2\modules\php\ext\ or anything else according to your extension_dir parameter in your

php.ini configuration file)

11. Open your php.ini file in any text editor and add the following lines to, just below the Windows extensions section (you can put it anywhere in the file)

zend_extension_ts="C:/WebServer/Apache2/modules/php/ext/php_xdebug-2.0.0-5.1.6.dll"xdebug.remote_enable=1xdebug.remote_handler=dbgpxdebug.remote_host=127.0.0.1xdebug.remote_mode=reqxdebug.idekey=defaultxdebug.remote_log="D:/www/ourcommunity.dev/log/xdebug.log"xdebug.remote_port=9000xdebug.show_exception_trace=0xdebug.show_local_vars=9xdebug.show_mem_delta=0xdebug.trace_format=0

10. Change “C:/WebServer/Apache2/modules/php/ext/php_xdebug-2.0.0-5.1.6.dll” to your extension folder and filename. Change “D:/www/ourcommunity.dev” to your application directory.

11. Reboot your computer (the easiest way to restart apache and other programs).

Nota Bene : If your Apache Server doesn’t restart, perhaps you’ll have to comment the line of the Zend Optimizer (I had to do this)

;zend_extension_manager.optimizer_ts = "C:\xampp\php\zendOptimizer\lib\Optimizer"

12. Load the phpinfo.php file again (http://localhost/supplier/phpinfo.php). You should see the Xdebug section in the phpinfo page.
13. You should see the DBGp menu shows up in the Notepad++ plugin menu.
14. Click the “Config…” item and configure the DBGp debugger as shown (the Remote Path and Local Path is the folder where your php files resides.
15. Create a test file, debugTest.php with the following lines in it :

Line $i";    }?>

Click Debugger under the Plugin -> DBGp menu to open the Debugger window at the lower section. Add a breakpoint on line 2 (click on the 2nd line and on the BreakPoint button, the one with a red point).

16. Make sure that you can load the debugTest.php with http://localhost/supplier/debugTest.php and it should show as below.

17. Add “?XDEBUG_SESSION_START=session_name” to the end of the url in the browser. Now the browser request is: http://localhost/supplier/debugTest.php?XDEBUG_SESSION_START=session_name (you can specify whatever session_name you want : test, dummy…)

You should see the Notepad++ icon on the taskbar blinking. If you open it up, the DBGp debug window comes to live. You can use the DBGp toolbar to step into, step over and step out and run the code.

BDGP Plugin Break Point

18. To see the global and local variables, select “Refresh local context on every step” and “Refresh global context on every step” in the DBGp configuration (Plugins/DBGp/Config… Np++ menu). It should be similar as the picture shown below.

19. Now you can see the global variables at the lower left hand corner. To access local variable in the program, select the variable then hit CTRL-F7. This put the selected variable into the Eval window. Click OK will show the current value of the variable, as shown below.
That is it. Good luck with your PHP project.

Special thanks to Damjan Cvetko (zobo) for answering my questions on setting up the DBGp on SourceForge.net. See the SourceForge.net Forumfor detail discussion:

Reference

  • Remote Debugging with Xdebug
  • essay help mastering writing skills
  • custom essay written professionally