本地开发环境域名:test.com:80
PHPstorm版本:2017.2
安装xdebug扩展
我用的是phpstudy,直接把xdebug的拓展打开就好了,不过需要在php.ini里面加一些配置,才能使用(就因为少加了参数配置,导致调试了好半天才弄好)
最终配置如下:[XDebug] xdebug.profiler_output_dir="D:\phpStudy\tmp\xdebug" xdebug.trace_output_dir="D:\phpStudy\tmp\xdebug" xdebug.remote_host = localhost xdebug.remote_port = 9000 xdebug.remote_enable = On xdebug.remote_handler = dbgp xdebug.idekey=PHPSTORM zend_extension="D:\phpStudy\php\php-5.6.27-nts\ext\php_xdebug.dll"
所有参数说明:
如果用的其他集成开发包,或者自己搭建的php环境的话。就需要自己去下载xdebug,然后修改php.ini,具体方法我就不赘述了。
安装Google xdebug helper 插件
安装好后,浏览器右上角右键点击 xdebug helper -> 选项 来进行配置。
配置PHPstorm
Google浏览器打开项目页面,打开debug
找到文件中需要打断点的地方,设置断点
浏览器访问,页面会停留在断点那里,打印数据如图:
至此,断点调试已经可以使用了。配置过程中,需要注意 php.ini 中 xdebug.remote_port 的端口需要与PHPstorm中xdebug的端口一直(此处php.ini使用的是9000,PHPstorm默认9000);还需要注意项目的默认端口80等。