今天下午一直在捣鼓如何用PhpStorm进行调试,查找了许多资料,零零碎碎的,因此本身弄篇文章记录一下步骤。php
使用brew安装xdebug,语法以下web
brew install homebrew/php/php<version number>-xdebug
到https://xdebug.org/download.php下载xdebug,版本必须是与php对应的版本apache
brew install homebrew/php/php56-xdebug
若是你不知道该下载哪一个版本的xdebug,xdebug网站有能够检测的地方(xdebug检测),把你的phpinfo()信息整个复制到文本框内,而后点击Analyse my phpinfo() output按钮,就会有相应的安装过程介绍。服务器
查看现有php版本phpstorm
$ php -v PHP 5.6.32 (cli) (built: Oct 27 2017 11:56:18) Copyright (c) 1997-2016 The PHP Group Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies with Xdebug v2.5.5, Copyright (c) 2002-2017, by Derick Rethans
下载完成后,解压压缩文件。把解压后的文件目录,整个复制到/usr/local/Cellar/php56/5.6.32_8/目录下ide
$ cd /usr/local/Cellar/php56/5.6.32_8/ $ phpize
若出现如下信息,则表示能够继续下一步网站
Configuring for: PHP Api Version: 20131106 Zend Module Api No: 20131226 Zend Extension Api No: 220131226
继续走流程ui
$ ./configure $ make $ cp modules/xdebug.so /usr/lib/php/extensions/no-debug-non-zts-20131226
最后建立/etc/php.ini文件.net
vi /etc/php.ini
添加这一行debug
zend_extension = /usr/lib/php/extensions/no-debug-non-zts-20131226/xdebug.so
重启web服务器
apachectl restart
使用phpinfo查看是否安装成功
<?php phpinfo(); ?>
虽然/etc/php.ini的都有默认配置,但这几个配置最好写一下
xdebug.remote_enable = On xdebug.remote_handler = dbgp xdebug.remote_host= localhost xdebug.remote_port = 9000 xdebug.idekey = PHPSTORM
打开PhpStorm,查看xdebug的基本信息
这里的端口须要与/etc/php.ini里xdebug.remote_port的端口一致
点击Edit Configurations
新建PHP Web Application
配置基本信息
配置Server
至此,Done!
博文做者:GarveyCalvin
博文出处:http://www.cnblogs.com/GarveyCalvin/ 本文版权归做者和博客园共有,欢迎转载,但须保留此段声明,并给出原文连接,谢谢合做!