{"id":5510,"date":"2021-01-04T11:30:44","date_gmt":"2021-01-04T11:30:44","guid":{"rendered":"https:\/\/blog.gwlin.com\/?p=5510"},"modified":"2023-03-30T22:16:22","modified_gmt":"2023-03-30T22:16:22","slug":"PHP xdebug+phpstorm\u8c03\u8bd5 \u914d\u7f6e","status":"publish","type":"post","link":"https:\/\/www.gwlin.com\/blog\/posts\/5510","title":{"rendered":"PHP xdebug+phpstorm\u8c03\u8bd5 \u914d\u7f6e"},"content":{"rendered":"<p>\u5728\u52a8\u624b\u914d\u7f6e\u4e4b\u524d\u5148\u4e86\u89e3\u4e00\u4e0bxdebug\u8c03\u8bd5\u7684\u539f\u7406\u3002<\/p>\n<p>\u6211\u4eec\u77e5\u9053\u6d4f\u89c8\u5668\u6253\u5f00\u7f51\u7ad9\u5730\u5740\u540e\uff0cweb\u670d\u52a1\u5668\u63a5\u6536\u5230\u8bf7\u6c42\u4f1a\u628a\u8bf7\u6c42\u901a\u8fc7fastcgi\u53d1\u9001\u7ed9php\u5904\u7406\u3002php\u5904\u7406\u5b8c\u6210\u540e\u628a\u6570\u636e\u8fd4\u56de\u7ed9web\u670d\u52a1\u5668\uff0cweb\u670d\u52a1\u5668\u518d\u53d1\u9001\u7ed9\u6d4f\u89c8\u5668\uff0c\u5b8c\u6210\u6574\u4e2a\u8bf7\u6c42\u8fc7\u7a0b\u3002\u800c\u5f53\u6211\u4eec\u5b89\u88c5\u4e86xdebug\u6269\u5c55\u540e\uff0cxdebug\u4f1a\u5c06\u8bf7\u6c42\u5468\u671f\u5185\u7684php\u8fd0\u884c\u72b6\u6001\u53d1\u9001\u7ed9\u6307\u5b9a\u7684\u63a5\u6536\u8005\u3002\u63a5\u6536\u8005\uff08\u6211\u4eec\u8fd9\u91cc\u662fphpstorm\uff09\u5219\u4f1a\u6253\u5370\u51fa\u6211\u4eec\u60f3\u770b\u5230\u7684\u8c03\u8bd5\u4fe1\u606f\u3002\u4e0b\u9762\u6211\u4eec\u5f00\u59cb\u914d\u7f6e\u3002<\/p>\n<p>1\u3001\u9996\u5148\u8981\u5b89\u88c5xdebug\uff0c\u5b89\u88c5\u65b9\u6cd5\u8fd9\u91cc\u4e0d\u8be6\u7ec6\u8bf4\u4e86\u3002windows\u4e0b\u8f7d\u5bf9\u5e94\u7248\u672c\u7684xdebug.dll\uff0clinux\u76f4\u63a5 apt install \u6216\u8005\u81ea\u5df1\u7f16\u8bd1\u90fd\u884c\u3002\u8981\u68c0\u67e5xdebug\u662f\u5426\u5b89\u88c5\u6210\u529f\uff0c\u770b\u4e00\u4e0b phpinfo() \u6709\u6ca1\u6709 xdebug \u5373\u53ef\u3002\u4e5f\u53ef\u4ee5\u5728\u547d\u4ee4\u884c\u4e0b\u8fd0\u884c php -v \uff0c\u5982\u679c\u6709xdebug\u5b57\u6837\uff0c\u5219\u8868\u793a\u5b89\u88c5\u6210\u529f\u3002<\/p>\n<p>2\u3001\u63a5\u4e0b\u6765\u8981\u914d\u7f6exdebug\u3002\u627e\u5230php\u7684\u914d\u7f6e\u6587\u4ef6\uff0c\u4e0d\u540c\u7684\u5b89\u88c5\u65b9\u5f0f\u53ef\u80fd\u4f1a\u5bfc\u81f4php\u7684\u914d\u7f6e\u6587\u4ef6\u653e\u5728\u4e0d\u540c\u7684\u4f4d\u7f6e\uff0c\u5728\u547d\u4ee4\u884c\u4e0b\u53ef\u4ee5\u7528 php --ini \u6765\u67e5\u770bphp\u52a0\u8f7d\u4e86\u54ea\u4e9b\u914d\u7f6e\u6587\u4ef6\u3002\u627e\u5230\u76f8\u5e94\u7684\u914d\u7f6e\u6587\u4ef6\u540e\u6211\u4eec\u6765\u770b\u4e00\u4e0b\u914d\u7f6e\u53c2\u6570\uff0c\u6700\u57fa\u672c\u7684\u914d\u7f6e\u53ea\u8981\u914d\u7f6e\u597d4\u4e2a\u53c2\u6570\u5c31\u884c\u3002<\/p>\n<pre><code class=\"prettyprint\" >[xdebug]\nxdebug.remote_enable=1 # \u5f00\u542f\u8fdc\u7a0b\u8c03\u8bd5\nxdebug.remote_host=xxx.xxx.xxx.xxx # \u8c03\u8bd5\u4fe1\u606f\u63a5\u6536\u8005\u7684IP\uff0c\u672c\u673a\u8c03\u8bd5\u5c31\u662f127.0.0.1\nxdebug.remote_port=9000 # \u63a5\u6536\u8005\u76d1\u542c\u8c03\u8bd5\u4fe1\u606f\u7684\u7aef\u53e3\uff0c\u5373phpstorm\u8981\u76d1\u542c\u7684\u7aef\u53e3\uff0c\u7528\u6765\u63a5\u53d7\u8c03\u8bd5\u4fe1\u606f\nxdebug.idekey=PHPSTORM # \u53d1\u9001\u6807\u793a\uff0cxdebug\u53ea\u6709\u5728\u8bf7\u6c42\u7684cookie\u4e2d\u542b\u6709idekey\u6240\u6307\u5b9a\u7684\u6807\u793a\u624d\u4f1a\u542f\u7528\u8c03\u8bd5\u6a21\u5f0f\uff0c\u5e76\u5c06\u4fe1\u606f\u53d1\u9001\u7ed9\u63a5\u6536\u8005\u3002&lt;br&gt;&lt;\/br&gt;<\/code><\/pre>\n<p>\u8fd8\u6709\u66f4\u591a\u53c2\u6570\u53ef\u4ee5\u81ea\u884c\u67e5\u770b\u5b98\u7f51\u624b\u518c\uff1a<a href=\"https:\/\/xdebug.org\/docs\/all_settings\">https:\/\/xdebug.org\/docs\/all_settings<\/a><\/p>\n<p>3\u3001phpstorm\u914d\u7f6e\uff0c\u4e3b\u8981\u6709\u4e24\u4e2a\u5730\u65b9\u3002<\/p>\n<p>3.1\u3001\u627e\u5230\u5982\u4e0b\u56fe\u7684\u914d\u7f6e\uff0cxdebug\u7684debug port\u586b\u4e0a\u521a\u521aphp\u914d\u7f6e\u7684\u63a5\u53d7\u7aef\u53e3\uff0cphpstorm\u4f1a\u76d1\u542c\u8fd9\u4e2a\u7aef\u53e3\uff0c\u63a5\u53d7xdebug\u53d1\u6765\u7684\u4fe1\u606f\u3002\u6ce8\u610f\u7aef\u53e3\u51b2\u7a81\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/files.gwlin.com\/images\/2019\/07\/30\/5d3fa2282398d.png\" alt=\"phpstorm xdebug\" \/><\/p>\n<p>3.2\u3001\u5982\u4e0b\u56fe\uff0c\u627e\u5230server\uff0c\u6dfb\u52a0\u8def\u5f84\u6620\u5c04\uff0c\u4e5f\u5c31\u662f\u5c06\u7f51\u7ad9\u7684\u57df\u540d\/IP\u3001\u7aef\u53e3\u548c\u6839\u76ee\u5f55\u6dfb\u52a0\u8fdb\u53bb\u3002\u5426\u5219phpstorm\u627e\u4e0d\u5230\u5bf9\u5e94\u7684\u9879\u76ee\u6587\u4ef6\uff0c\u6253\u4e0d\u4e86\u65ad\u70b9\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/files.gwlin.com\/images\/2019\/07\/30\/5d3fa59e9f9c8.png\" alt=\"phpstorm xdebug\" \/><\/p>\n<p>4\u3001\u5b89\u88c5\u6d4f\u89c8\u5668\u6269\u5c55\uff0c\u8fd9\u4e00\u6b65\u5e94\u8be5\u4e0d\u662f\u5fc5\u987b\u7684\uff0c\u770b\u81ea\u5df1\u5b9e\u9645\u7684\u5f00\u53d1\u73af\u5883\u3002chrome\u5b89\u88c5xdebug\u6269\u5c55\u542f\u7528\u540e\uff0c\u4f1a\u81ea\u52a8\u5728\u9700\u8981\u8c03\u8bd5\u7684\u7f51\u7ad9\u6dfb\u52a0idekey\u6807\u8bc6\u4ee5\u65b9\u4fbf\u4f7f\u7528\uff0c\u4e0d\u9700\u8981\u6bcf\u6b21\u90fd\u624b\u52a8\u6dfb\u52a0\u3002<\/p>\n<p>5\u3001phpstorm\u5f00\u542f\u76d1\u542c\u8c03\u8bd5\u7aef\u53e3\uff0cstart listening for php xdebug connections\uff0c\u5982\u4e0b\u56fe<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/files.gwlin.com\/images\/2019\/07\/30\/5d404268972a2.png\" alt=\"phpstorm xdebug\" \/><\/p>\n<p>\u597d\u4e86\uff0c\u63a5\u4e0b\u6765\u5c31\u662f\u6109\u5feb\uff08\u751f\u4e0d\u5982\u6b7b\uff09\u7684\u8c03\u8bd5\u65f6\u95f4\u4e86\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5728\u52a8\u624b\u914d\u7f6e\u4e4b\u524d\u5148\u4e86\u89e3\u4e00\u4e0bxdebug\u8c03\u8bd5\u7684\u539f\u7406\u3002 \u6211\u4eec\u77e5\u9053\u6d4f\u89c8\u5668\u6253\u5f00\u7f51\u7ad9\u5730\u5740\u540e\uff0cweb\u670d\u52a1\u5668\u63a5\u6536\u5230\u8bf7\u6c42\u4f1a\u628a\u8bf7\u6c42 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[179],"tags":[],"class_list":["post-5510","post","type-post","status-publish","format-standard","hentry","category-notes"],"_links":{"self":[{"href":"https:\/\/www.gwlin.com\/blog\/wp-json\/wp\/v2\/posts\/5510","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.gwlin.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.gwlin.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.gwlin.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.gwlin.com\/blog\/wp-json\/wp\/v2\/comments?post=5510"}],"version-history":[{"count":0,"href":"https:\/\/www.gwlin.com\/blog\/wp-json\/wp\/v2\/posts\/5510\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.gwlin.com\/blog\/wp-json\/wp\/v2\/media?parent=5510"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.gwlin.com\/blog\/wp-json\/wp\/v2\/categories?post=5510"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.gwlin.com\/blog\/wp-json\/wp\/v2\/tags?post=5510"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}