Home >Backend Development >PHP Tutorial >Set breakpoints to debug and run PHP source code in Zend Studio 125
This article solves the following problem: After setting a breakpoint in Zend Studio and then debugging and running (Debug As PHP Web Application), I found that the website ran normally and the breakpoint did not take effect at all.
The breakpoint does not take effect, mainly because the debugger is not configured properly.
In fact, Zend Studio already comes with the ZendDebugger debugger and has been integrated with the built-in PHP CLI environment. But to debug the Web server + PHP program we installed ourselves, we have to do additional configuration work.
Modify php.ini and add settings such as zend_extension
Add the following settings at the end of php.ini:
<code>zend_extension = "C:<span>\Program</span> Files<span>\Zend</span><span>\Zend</span> Studio 12.5.1<span>\plugins</span><span>\com</span>.zend.php.debug.debugger.php56.win32_12.5.0.v20150415-1131<span>\resources</span><span>\php</span>56<span>\ZendDebugger</span>.dll" zend_debugger.allow_hosts = "127.0.0.1"</code>
The value of zend_extension is the full path file name of the Zend Debugger plug-in, which is located in the Zend Studio installation directory. Search for ZendDebugger.dll
to find it.
Note that there are two copies of this DLL in the Zend installation directory, one for PHP 5.6 and the other for PHP 5.5. You need to choose the one that is consistent with your PHP installation version. (The Zend official website also provides Zend Debugger for separate download.)
After modifying the php.ini file and saving it to disk, please restart PHP (php-cgi, PHP-FPM, etc., or Web server) to ensure that php.ini is reloaded.
Note: ZendDebugger is the VC11 NTS version (Non Thread Safe) and must be used with the NTS version of PHP. In other words, the TS version of PHP cannot use ZendDebugger (loading fails). See the PHP official website for instructions on TS and NTS versions.
Place dummy.php in the root directory of the Web server
Create the file dummy.php
in the Ngninx document root directory html, with the following content:
<code><?php <span>@<span>ini_set(<span>'zend_monitor.enable'</span>, <span>0</span>)</span>;</span><span>if(@<span>function_exists(<span>'output_cache_disable'</span>)</span>)</span> { <span>@<span>output_cache_disable()</span>;</span> } <span>if(<span>isset($_GET[<span>'debugger_connect'</span>])</span> && $_GET[<span>'debugger_connect'</span>] == <span>1</span>)</span> { <span>if(<span>function_exists(<span>'debugger_connect'</span>)</span>)</span> { <span>debugger_connect()</span>; <span>exit()</span>; } else { echo "No connector is installed."; } }</code>
Start debugging
In the Zend Studio project management window, right-click the mouse index.php, click the selection menu Debug As -> PHP Web Application and confirm to start the debugging process. The debugger will interrupt at the first line of PHP code. You can also use the shortcut keys Ctrl + Shift + B to set other breakpoints. F8 will continue to run. If the breakpoint interrupts the operation as expected, it means that the above configuration is successful. Copyright Statement: This article is original by blogger Liigo and may not be reproduced without authorization.
The above introduces how to set breakpoints to debug and run PHP source code in Zend Studio 125, including the relevant aspects. I hope it will be helpful to friends who are interested in PHP tutorials.