首先安装 MAMP PRO ,它自带xdebug,不用再单独安装 xdebug 了。
一、在 MAMP PRO 的主窗口:
1. 点击 Hosts,设置根目录,Document root 为指定的目录。
2. 点击 PHP,选中 Xdebug(Debugger)。
二、在 phpstorm -> Preference -> Languages & Frameworks -> PHP -> Debug 中
Debug port: 9000,其它选中三个对号(默认不用更改)
三、在 phpstorm -> Preference -> Languages & Frameworks -> PHP -> Servers 中
添加服务器:
Name:localhost Host :localhost Port:8888(与Apache一致) Debugger:Xdebug
四、在phpstorm工具栏,点击箭头,Edit Configuration
添加 PHP Web Page (PHP Web Application)
Name:起个名字
Server:localhost Start URL:/
Browser:选择浏览器
五、注意
不用更改 php.ini 内容。
如果想查看 php.ini ,在 MAMP PRO -> File ->Edit Template -> PHP(php.ini) -> 选择相应版本
不用在浏览器端,安装小虫子插件,即chrom浏览器不用安装Xdebug扩展
如果没有命中断点,点击“红色方块左边按钮”,start listening for PHP debug connections
六、Postman调试API接口
下载Postmen扩展程序
https://chrome.google.com/webstore/detail/postman/fhbjgbiflinjbdggehcddcbncdddomop/related
安装后会自动出现postman图标,点击工具栏 Interceptor 打开拦截器,就会命中断点