您的位置:首页 > 编程语言 > PHP开发

phpstorm设置断点调试

2017-07-31 16:22 495 查看
前言:
何为DEBUG?
相信很多程序员都知道debug这个单词,也明白它的意思,但是对于这词的由来,恐怕少有人知道。关于debug的由来,要追溯到1937年。1937年,美国青年霍德华.艾肯找到IBM公司为其投资200万美元研制计算机,第一台成品艾肯把它取名为:马克1号(mark1),又叫“自动序列受控计算机”,从这时起IBM公司由生产制表机,肉铺磅秤,咖啡研磨机等乱七八糟玩意儿的行业,正式跨进“计算机”领地。为马克1号编制程序的是哈佛的一位女数学家格蕾丝·莫雷·赫伯,有一天,她在调试程序时出现故障,拆开继电器后,发现有只飞蛾被夹扁在触点中间,从而“卡”住了机器的运行。于是,霍波诙谐的把程序故障统称为“臭虫(BUG)”,把排除程序故障叫DEBUG,而这奇怪的“称呼”,后来成为计算机领域的专业行话。从而debug意为程序除错的意思。

(本文为windows下的安装流程,mac 版的童鞋可查看:mac下phpstorm+Xdebug断点调试PHP

官方给出的步骤:

Zero-configuration Web Application Debugging with Xdebug and PhpStorm

运行环境:

PHPSTORM版本 : 8.0.1

PHP版本 : 5.6.2

xdebug版本:php_xdebug-2.2.5-5.6-vc11-x86_64.dll

ps : php版本和xdebug版本一定要相对应

点击下载Xdebug

1. PHP安装xdebug扩展

php.ini的配置,下面的配置仅供参考,路径要换成自己的!

[plain] view plain copy

print?

[xdebug]

zend_extension="D:\wamp\php-5.6.2-x64\ext\php_xdebug-2.2.5-5.6-vc11-x86_64.dll"

xdebug.remote_enable = On

xdebug.remote_handler = dbgp

xdebug.remote_host= localhost

xdebug.remote_port = 9000

xdebug.idekey = PHPSTORM

[xdebug]
zend_extension="D:\wamp\php-5.6.2-x64\ext\php_xdebug-2.2.5-5.6-vc11-x86_64.dll"
xdebug.remote_enable = On
xdebug.remote_handler = dbgp
xdebug.remote_host= localhost
xdebug.remote_port = 9000
xdebug.idekey = PHPSTORM


ps : remote_handler 、remote_host、remote_port 这些都有默认值,但还是建议设置下,至少知道要设置这些参数~

查看phpinfo~





【或者使用PHPstudy:其他选项菜单/PHP扩展设置/PHP扩展/XDEBUG打上对钩】

2.PHPSTORM设置

楼主以前一直用zendstudio,刚开始用phpstorm非常蛋疼,用了一段时间后发现还挺好用的~

1.首先检查phpstorm的xdebug配置

这里的debug port要和php.ini里面的xdebug.remote_port相一致!默认是9000,如果9000端口被占用的话,可以改成其他端口。







phpstorm配置

客户端调试,打开phpStorm,进入File>Settings>PHP>Servers,这里要填写服务器端的相关信息,name填localhost,host填localhost,port填80,debugger选XDebug

进入File>Settings>PHP>Debug,看到XDebug选项卡,port填9000,其他默认

进入File>Settings>PHP>Debug>DBGp Proxy,IDE key 填 phpStorm,host 填localhost,port 填80

点OK退出设置。



从这一步开始有两种方式

第一种:

2. 设置debug.(也可以使用监听模式)





添加本地的 web server~

www.mall.com是我本地的服务







3.开始调试

打好第一个断点,shift + F9就可以了

打好第一个断点,选中配置的debug, 按旁边的臭虫 按钮



第二种:

2.使用google浏览器,安装一个插件:xdebug helper

2.1右键选择



选择



点击



点亮甲虫,打上断点,刷新页面即可



或者还是看不懂,好吧,那请看下面链接:

http://wenku.baidu.com/link?url=osFXlDZtbYW2yOxJYwKukXButWW647d2d87-d69F56FmbU1Wi7YNK-KCGcrL-car-o1U_r2Y0xkXnqoZw2I87FsKdMb7Z9N9pZZvB1a8Lrq

常见问题:

[plain] view plain copy

print?

Debug session was finished without being paused

It may be caused by path mappings misconfiguration or not synchronized local and remote projects.

To figure out the problem check path mappings configuration for 'www.test.com' server at PHP|Servers or enable Break at first line in PHP scripts option (from Run menu).

Debug session was finished without being paused
It may be caused by path mappings misconfiguration or not synchronized local and remote projects.
To figure out the problem check path mappings configuration for 'www.test.com' server at PHP|Servers or enable Break at first line in PHP scripts option (from Run menu).

没有打断点或者调试没有被监测到,碰到这个问题,看看路径配置对了吗是否能访问到

本文地址:http://blog.csdn.NET/ty_hf/article/details/50768702
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: