The debug of a PHP program, either CLI or Web, requires the use of a third-party debug tool. Prior to PHP5.6, the debug function itself was limited to log output.
It is recommended to use the free xdebug. Xdebug as a zend extension exists. It can be installed by phpize alone after the installation of PHP.
A few notes on the installation of Xdebug
- If you do not know what to download Xdebug version, can be here, by uploading phpinfo information, the system gives recommendations: http://xdebug.org/wizard.php
- After installation, you need to specify the xdebug.so mode in php.ini, which may vary depending on the PHP version. For details, see this: http://xdebug.org/docs/all#configure-php
- Make install if the installation is not successful, you can go to the Modules folder, manually copy xdebug.so to 1 under the suggested folder
A few notes on the use of Xdebug
- If you need to set breakpoints and single-step tracking, you can use the debugclient that comes with Xdebug. Located under the Debugclient folder. Installation method: Http://xdebug.org/docs/all#debugclient
- XDEBUG code tracking is done through remote debug; Debugclient is actually a server for listening and waiting for debug requests; All breakpoints are set through Debugclient. For detailed control commands, refer to: http://xdebug.org/docs-dbgp.php
- PHP uses debugclient as the server rather than the Java-like remote debug mode. The reason is that PHP code is not similar to Java compilation execution can directly see the source code, on the other hand, debugclient can be based on the session settings, to distinguish which requests need to debug and single-step tracking. This is very meaningful for multiple concurrent Web applications (of course, Java can also be implemented by setting conditional breakpoints). Reference: Http://xdebug.org/docs/all#activate_debugger
- For the CLI PHP program to debug, you need to set xdebug_config. Refer to: Http://stackoverflow.com/questions/13284795/setting-xdebug-breakpoints-solely-in-command-line
About GDB Debug PHP program, mainly for the Zend engine itself, PHP source code and extension of the Debug. This is why the PHP source comes with the gdb script. Gdbinit reason.
PHP program Z xdebug Tool Brief use method