在PHP中,通常情况下会使用Xdebug工具来进行调试,具体的配置如下:
首先需要在php.ini文件中添加如下的配置语句:
[XDebug]
zend_extension = "D:\xampp\php\ext\php_xdebug.dll"
xdebug.remote_enable=on
xdebug.idekey='PHPSTORM'
xdebug.remote_host=localhost
xdebug.remote_port=9001
xdebug.remote_handler=dbgp
xdebug.remote_mode = req
xdebug.remote_log="D:\XDebugLog\xdebug.log"
这其中,zend_extension用来指定xdebug插件的存储位置,由于本教程使用的是xampp包,在该安装包中已经集成了xdebug插件,所以在配置中就直接使用xampp中所提供的dll文件。xdebug.remote_port用来指定xdebug插件的监听端口号。这里所配置的端口号需要和在PHPStorm中所配置的端口号保持一致。PHPStorm中,在 File->settings->Language&Frameworks->Debug中进行xdebug监听端口号的设置。

当上述配置结束后,需要重启Apache服务器。重启服务器后,就可以通过PHPStorm进行PHP程序的调试了。要强调的一点是,如果在本机进行开发时,将PHP项目部署到了本机Apache服务器的htdocs文件夹或其他虚拟目录时,在配置server时,需要对项目路径进行映射,否则将无法正常调试。

在这里需要强调是的,映射时一定要填写项目的绝对路径。当上述配置结束后,就可以进行项目的调试了。首先点击IDE环境中的
按钮:

待按钮变为

点击IDE环境中的
绿色Debug符号,

就可以进行项目调试。
网友评论