Today hastened to engage in this
Operating environment:
phpStorm 2018
PHP 5.45 nts VC9
0x01 PHP extensions installed xdebug
Before their own equipment has not been installed from the original version of the problem
Download: https: //xdebug.org/download.php
php.ini configuration:
[Xdebug] zend_extension = "D: \ phpstudy \ PHPTutorial \ PHP \ PHP-5.4.45 \ EXT \ php_xdebug.dll" # specify the absolute path to the file extension Xdebug xdebug.auto_trace = ON # Enable the code automatically track xdebug.collect_params = on # allowed to collect the variable parameters passed to the function xdebug.collect_return = ON # allowed to collect the return value of the function call xdebug.trace_output_dir =: "D \ phpstudy \ PHPTutorial \ tmp \ Xdebug" # storage directory specified stack trace file xdebug.profiler_enable = ON # Xdebug performance analysis is enabled, and create performance information file xdebug.profiler_output_dir = "D: \ phpstudy \ PHPTutorial \ tmp \ xdebug" # specify the performance analysis information file output directory xdebug.remote_enable = ON # is turned on remote debugging xdebug .remote_handler = dbgp # Specified remote debugging processing protocol xdebug.remote_host = localhost # Specifies the host name of the remote debugging xdebug.remote_port = 9000 # specify the port number of the remote debugging xdebug.idekey PhpStorm = # that are passed to the debugger processing program DBGp IDE Key
Save php.ini, restart apache checks for success turned xdebug service.
You can also view the php -m
D:\phpstudy\PHPTutorial\php\php-5.4.45-nts>php -m [PHP Modules] bcmath bz2 calendar Core ctype curl date dom ereg filter ftp gd hash iconv json libxml mbstring mcrypt mhash mysql mysqli mysqlnd odbc pcre PDO pdo_mysql PDO_ODBC pdo_sqlite Phar Reflection session SimpleXML sockets SPL sqlite3 standard tokenizer wddx xdebug xml xmlreader xmlrpc xmlwriter xsl Zend Guard Loader zip zlib [Zend Modules] Xdebug Zend Guard Loader
0x02 phpstorm 配置
配置对应php版本
Debug端口配置:
IDEKEY配置
Server配置
PHP Web Application配置
进入Run> Debug configurations,点+号选择PHP Web Page,Server选填localhost,Start URL填你要访问的页面(如:/index.php), Browser 默认或者选chrome
0x03 浏览器插件断点调试
网上很多谷歌xdebug插件 我还是喜欢火狐
在PHPStorm中创建项目,在代码中设置断点。点击phpstorm run>start listening或者右上角的小电话开启监听。进入需要调试的页面,点击火狐右上角的“臭虫”开始调试。
分析代码性能
你也可以利用WinCacheGrind或者QCacheGrind软件和xdebug生成的cachegrind.out文件分析PHP脚本的性能。
下载地址:
http://sourceforge.net/projects/wincachegrind/
http://sourceforge.net/projects/qcachegrindwin/
你也可以使用其他工具分析,参照这里:
https://xdebug.org/docs/profiler
参考资料
- xdebug帮助文档: https://xdebug.org/docs/
- IDE远程调试:https://xdebug.org/docs/remote