企业🤖AI Agent构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
[TOC] ## 概述 [官方网站: http://www.mpsoftware.dk/phpdesigner.php](http://www.mpsoftware.dk/phpdesigner.php) ## 调试 ### Debug with Xdebug 来源于phpDesigner8 的帮助手册。 Debug with Xdebug allows the programmer to analyze, evaluate and find errors in the code line by line. #### Configuration In order to use Xdebug you must have PHP installed local on your computer configured with the Xdebug extesion. By default, phpDesigner comes with a PHP package and Xdebug. If not, please follow these steps Download the latest PHP 5.x.x. package (not the installer) from [http://www.php.net ](http://www.php.net) Download the Xdebug extension for the PHP version you have installed in the previous step from [http://www.php.net ](http://www.xdebug.com). For example if you have PHP 5.3.1 installed, you need Xdebug 5.3 Place the Xdebug extension in the extension folder where you installed PHP, for example c:\...\PHP\ext In the folder where you installed PHP, open the file php.ini. Add a new section called \[Xdebug] in the file php.ini: > **\[XDebug]** > zend_extension="./ext/php_xdebug.dll" xdebug.remote_enable=true xdebug.remote_host=127.0.0.1 xdebug.remote_port=9000 xdebug.remote_handler=dbgp Configure phpDesigner to know where to find the PHP interpreter (php.exe, win-php.exe or php-cgi.exe). 1. On the Tools menu, point to Preferences 2. Select Debugger 3. In the field 'PHP' type in the path for the PHP interpreter (.exe), or click the Browse button to locate the PHP interpreter #### Sessions Start a debug session from within the IDE or from the web browser and execute your script until the first breakpoint or error occurs. In order to start a debug session the Xdebug server must be started. You can start, restart or stop the Xdebug server on the Debug menu, select Xdebug IDE server. * Run/Continue On the Debug menu, select Debug or press F9. When a debug session has been paused you can continue the debug session by pressing F9. * Step into/over This will start the debug session as in Run but will pause the execution at the first line of the script allowing you to step through the code. On the Debug menu, select Step into or press F7. On the Debug menu, select Step over or press F8. * Run to cursor This will start the debug session as in Run but will pause the execution until the line at cursor is reached. If any breakpoints or errors occurs before the line at cursor is reached the execution might be paused. On the Debug menu, select Run to cursor or press F4. * Run until return This will start the debug session as in Run but will pause when pressing the return key. If any breakpoints or errors occurs before the line at cursor is reached the execution might be paused. * Start the debug session from the web browser To start a debug session from the web browser, execute the script you want to debug in the web browser. phpDesigner 2008 will break at the breakpoints you have set for that script or if any errors occours. #### Breakpoints Use breakpoints to signal the debugger to temporarily suspend execution of your script at a certain point. Here you can examine your script for violations or bugs. Execution can be resumed at any time. >On the View menu, click Tool Panels and select Breakpoints. * Insert/remove a breakpoint On the Debug menu, click Toggle breakpoint or F5 * Enable breakpoint To enable a breakpoint, go to the breakpoint window and right-click on the row and select 'enable'. * Disable breakpoint Disabling a breakpoint makes the breakpoint inactive without removing it. To disable a breakpoint, go to the breakpoint window and right-click on the row and select 'disable'. #### Call stack Trace the course of the executions in your script throughout the debugging session. >On the View menu, click Tool Panels and select Call stack. #### Variables Display the value of all global and local variables throughout the debugging session. >On the View menu, click Tool Panels and select Variables. #### Watches Monitor variables, objects, properties etc. throughout the debugging session. Monitored variables should start with a "$" (dollar sign). >On the View menu, click Tool Panels and select Watches. #### Evaluation Evaluate and test expressions in your script. Manipulate variables direct during a debugging session. Manipulated or injected variables will affect the value of the variable when the execution of the script continues. Move the cursor upon variables to see their values. >On the View menu, click Tool Panels and select Evaluation. #### Log Messages that Xdebug sends to phpDesigner. >On the View menu, click Tool Panels and select Log. ### Profile with Xdebug phpDesigner provides support for Xdebug’s profiler. Analyze your code and determine bottlenecks or see which parts of your code are slow and could use a speed boost. #### Configuration Xdebug outputs profiling information in the form of a cachegrind compatible file. In order to view a cachegrind file you must have a program as WinCacheGrind in order to analyze your profiling data installed. WinCacheGrind can be downloaded free of charge at [http://sourceforge.net/projects/wincachegrind ](http://sourceforge.net/projects/wincachegrind) Configure phpDesigner to work with WinCacheGrind: 1. On the Tools menu, point to Preferences 2. Navigate to Profiler 3. Type in the path of where to locate WinCacheGrind (.exe) To enable the profiler in Xdebug, you must have PHP installed and add the xDebug extension to your PHP configuration. To enable Xdebug's profiler, add the following line to php.ini in the \[Xdebug] section: >xdebug.profiler_enable=on Specify the Xdebug's profiler output directory, add the following line to php.ini in the \[Xdebug] section: >xdebug.profiler_out_dir="..." Replace "..." with an absolute path, for example “c:\program files\phpDesigner\php\profiler” Add the same output path in phpDesigner: 1. On the Tools menu, point to Preferences 2. Navigate to Profiler 3. Type in the path for the output directory #### Usage * On the Debug menu, click Profile * Select Xdebug profile, click Ok