php的debug环境搭建

公司使用php作为开发语言,而且php运行环境和 javaweb+eclipse 环境不同,需要自行配置调试环境,留下记录,如果有遗漏欢迎留言。

目标是搭建一个由浏览器发起,到开发工具拦截的调试环境。

工具:phpstorm,phpstudy2016,XDebug。

版本:php-7.0.12-nts + Nginx。

环境:windows。

环境配置主要分2个部分,即:phpstorm和php-nts部分。

1. phpstorm配置:

顺序点击File | Settings | Languages & Frameworks | PHP进入配置页面 ,php language level 选择7,CLI interpreter 选择phpStudy 里的对应php版本 \phpStudy\php\php-7.0.12-nts\php.exe

扫描二维码关注公众号,回复: 3655289 查看本文章

这时候可以在phpstorm里新建php文件,右键debug代码内容。要想调试本地代码还需要以下配置:

进入配置:File | Settings | Languages & Frameworks | PHP | Servers 添加localhost。

如果9000端口被占用可以修改debug端口:

配置路径是:File | Settings | Languages & Frameworks | PHP | Debug

2.给php安装xdebug扩展 https://xdebug.org/download.php

下载xdebug要对应好php和系统VC版本,如果分不清版本网站还提供了 custom installation instructions.功能,方便顺利引入。这里我用的就是custom installation instructions

把php -i 输出的信息填入白框里,点击下面的分析按钮会出现适应xdebug的版本和提示操作步骤。

不知道怎样获取phpinfo信息, 可以在cmd窗口,cd到phpStudy\php\php-7.0.12-nts 目录下,使用 php -i > info.txt 命令把信息写进文件再粘贴出来。

按提示吧xdebug扩展文件放到ext里面:

配置php.ini [XDebug]

[XDebug]
zend_extension=E:\phpStudy\php\php-7.0.12-nts\ext\php_xdebug-2.6.0-7.0-vc14-nts.dll
xdebug.remote_port = 9001
xdebug.remote_enable=On
xdebug.remote_autostart=On
xdebug.remote_log="E:/0Develop/php/xdebug.log"

配置完成后重启phpstudy,打电话监听debug连接,这样从浏览器操作就可以phpstorm里使用断点调试了

猜你喜欢

转载自blog.csdn.net/weixin_40393909/article/details/81295879