{"id":181793,"date":"2024-05-08T21:05:27","date_gmt":"2024-05-08T13:05:27","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/181793.html"},"modified":"2024-05-08T21:05:38","modified_gmt":"2024-05-08T13:05:38","slug":"sublime-text-3-%e5%a6%82%e4%bd%95%e6%a0%bc%e5%bc%8f%e5%8c%96php%e4%bb%a3%e7%a0%81","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/181793.html","title":{"rendered":"sublime text 3 \u5982\u4f55\u683c\u5f0f\u5316PHP\u4ee3\u7801"},"content":{"rendered":"<p style=\"text-align:center\"><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/27071645\/7dcee916-77a5-410a-a431-9b6b9c4b9076.webp\" alt=\"sublime text 3 \u5982\u4f55\u683c\u5f0f\u5316PHP\u4ee3\u7801\" \/><\/p>\n<p><p>Sublime Text 3 \u683c\u5f0f\u5316PHP\u4ee3\u7801\u53ef\u4ee5\u901a\u8fc7\u5b89\u88c5\u63d2\u4ef6\u3001\u4f7f\u7528\u5185\u5efa\u529f\u80fd\u3001\u4ee5\u53ca\u914d\u5408\u5916\u90e8\u5de5\u5177\u7b49\u65b9\u6cd5\u5b9e\u73b0\u3002\u9996\u5148\u3001\u4f7f\u7528<code>Package Control<\/code>\u5b89\u88c5<code>phpfmt<\/code>\u63d2\u4ef6\u662f\u6700\u76f4\u63a5\u7684\u65b9\u5f0f\u3002\u5176\u6b21\u3001\u53ef\u4ee5\u901a\u8fc7\u8bbe\u7f6e\u952e\u76d8\u5feb\u6377\u65b9\u5f0f\u6216\u4f7f\u7528\u547d\u4ee4\u9762\u677f\u6765\u5feb\u901f\u683c\u5f0f\u5316\u4ee3\u7801\u3002\u800c\u5728\u6df1\u5165\u4f7f\u7528\u8fc7\u7a0b\u4e2d\uff0c\u7ed3\u5408\u5916\u90e8\u683c\u5f0f\u5316\u5de5\u5177\uff0c\u4f8b\u5982<code>PHP-CS-Fixer<\/code>\u6216<code>Prettify<\/code>\uff0c\u53ef\u4ee5\u8fdb\u4e00\u6b65\u63d0\u9ad8\u683c\u5f0f\u5316\u6548\u7387\u548c\u8d28\u91cf\u3002\u5b89\u88c5<code>phpfmt<\/code>\u63d2\u4ef6\u4e0d\u4ec5\u80fd\u5e2e\u52a9\u5f00\u53d1\u8005\u5feb\u901f\u7f8e\u5316\u4ee3\u7801\uff0c\u8fd8\u80fd\u6839\u636ePSR\u6807\u51c6\u81ea\u52a8\u8c03\u6574\u4ee3\u7801\u683c\u5f0f\uff0c\u6781\u5927\u63d0\u9ad8\u5f00\u53d1\u6548\u7387\u548c\u4ee3\u7801\u53ef\u8bfb\u6027\u3002<\/p>\n<\/p>\n<p><p>\u4e00\u3001 <strong>\u5b89\u88c5PHP\u683c\u5f0f\u5316\u63d2\u4ef6<\/strong><\/p>\n<\/p>\n<p><p>\u5b89\u88c5<code>phpfmt<\/code>\u63d2\u4ef6\u662f\u901a\u8fc7Sublime Text 3\u683c\u5f0f\u5316PHP\u4ee3\u7801\u7684\u9996\u9009\u65b9\u6cd5\u3002\u8fd9\u4e2a\u63d2\u4ef6\u4e3a\u5f00\u53d1\u8005\u63d0\u4f9b\u4e86\u4e00\u7cfb\u5217\u5f3a\u5927\u7684\u4ee3\u7801\u683c\u5f0f\u5316\u529f\u80fd\uff0c\u5305\u62ec\u81ea\u52a8\u7f29\u8fdb\u3001\u4ee3\u7801\u89c4\u8303\u5316\u4ee5\u53ca\u884c\u5bbd\u8c03\u6574\u7b49\u3002<\/p>\n<\/p>\n<ul>\n<li>\u9996\u5148\uff0c\u901a\u8fc7<code>Ctrl+Shift+P<\/code>\uff08MacOS\u662f<code>Cmd+Shift+P<\/code>\uff09\u6253\u5f00\u547d\u4ee4\u9762\u677f\uff0c\u8f93\u5165<code>Install Package<\/code>\uff0c\u9009\u4e2d<code>Package Control: Install Package<\/code>\u540e\u56de\u8f66\u3002\u5728\u5f39\u51fa\u7684\u5217\u8868\u4e2d\u641c\u7d22<code>phpfmt<\/code>\uff0c\u7136\u540e\u5b89\u88c5\u3002<\/li>\n<li>\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u4f60\u53ef\u4ee5\u901a\u8fc7\u83dc\u5355\u680f<code>Preferences -&gt; Package Settings -&gt; phpfmt -&gt; Settings \u2013 Default<\/code>\u6765\u67e5\u770b\u9ed8\u8ba4\u914d\u7f6e\uff0c<code>Settings - User<\/code>\u6765\u81ea\u5b9a\u4e49\u914d\u7f6e\u3002\u5f53\u7136\uff0c\u9ed8\u8ba4\u8bbe\u7f6e\u5df2\u7ecf\u8db3\u591f\u4e00\u822c\u5f00\u53d1\u4f7f\u7528\u3002<\/li>\n<\/ul>\n<p><p>\u4e8c\u3001 <strong>\u914d\u7f6e\u952e\u76d8\u5feb\u6377\u65b9\u5f0f\u548c\u547d\u4ee4\u9762\u677f<\/strong><\/p>\n<\/p>\n<p><p>\u914d\u7f6e\u5feb\u6377\u952e\u548c\u547d\u4ee4\u9762\u677f\u53ef\u4ee5\u4f7f\u5f97\u683c\u5f0f\u5316\u8fc7\u7a0b\u66f4\u52a0\u4fbf\u6377\u3002<\/p>\n<\/p>\n<ul>\n<li>\u8981\u8bbe\u7f6e\u952e\u76d8\u5feb\u6377\u65b9\u5f0f\uff0c\u6253\u5f00<code>Preferences -&gt; Key Bindings<\/code>\u3002\u5728\u53f3\u4fa7\u7528\u6237\u8bbe\u7f6e\u6587\u4ef6\u4e2d\uff0c\u6dfb\u52a0\u4e00\u4e2a\u5feb\u6377\u952e\u914d\u7f6e\u9879\uff0c\u4f8b\u5982\uff1a<code>{ &quot;keys&quot;: [&quot;ctrl+alt+f&quot;], &quot;command&quot;: &quot;phpfmt_format&quot; }<\/code>\u3002<\/li>\n<li>\u82e5\u8981\u901a\u8fc7\u547d\u4ee4\u9762\u677f\u4f7f\u7528<code>phpfmt<\/code>\uff0c\u53ea\u9700\u8981\u6253\u5f00\u547d\u4ee4\u9762\u677f\uff08<code>Ctrl+Shift+P<\/code>\u6216<code>Cmd+Shift+P<\/code>\uff09\uff0c\u7136\u540e\u8f93\u5165<code>phpfmt<\/code>\u5373\u53ef\u770b\u5230\u76f8\u5173\u7684\u683c\u5f0f\u5316\u547d\u4ee4\u3002<\/li>\n<\/ul>\n<p><p>\u4e09\u3001 <strong>\u7ed3\u5408\u5916\u90e8\u683c\u5f0f\u5316\u5de5\u5177<\/strong><\/p>\n<\/p>\n<p><p>\u5bf9\u4e8e\u66f4\u9ad8\u7ea7\u7684\u683c\u5f0f\u5316\u9700\u6c42\uff0c\u7ed3\u5408\u5916\u90e8\u683c\u5f0f\u5316\u5de5\u5177\uff0c\u5982<code>PHP-CS-Fixer<\/code>\uff0c\u53ef\u4ee5\u66f4\u7cbe\u7ec6\u5730\u63a7\u5236\u4ee3\u7801\u98ce\u683c\u3002<\/p>\n<\/p>\n<ul>\n<li>\u5b89\u88c5<code>PHP-CS-Fixer<\/code>\u4e4b\u540e\uff0c\u9700\u8981\u5728Sublime Text\u4e2d\u914d\u7f6e\u5176\u8def\u5f84\u3002\u8fd9\u53ef\u4ee5\u901a\u8fc7\u7f16\u8f91<code>phpfmt<\/code>\u7684\u7528\u6237\u914d\u7f6e\u6587\u4ef6\u6765\u5b9e\u73b0\uff0c\u6dfb\u52a0<code>&quot;php_bin&quot;: &quot;\u8def\u5f84\/to\/php-cs-fixer&quot;<\/code>\u3002<\/li>\n<li>\u63a5\u7740\uff0c\u60a8\u53ef\u4ee5\u901a\u8fc7<code>phpfmt<\/code>\u63d2\u4ef6\u7684\u81ea\u5b9a\u4e49\u811a\u672c\u529f\u80fd\uff0c\u8fd0\u884c<code>PHP-CS-Fixer<\/code>\u6765\u683c\u5f0f\u5316\u4ee3\u7801\u3002\u8fd9\u4e0d\u4ec5\u589e\u52a0\u4e86\u683c\u5f0f\u5316\u7684\u7075\u6d3b\u6027\uff0c\u8fd8\u80fd\u6309\u9879\u76ee\u9700\u8981\u81ea\u5b9a\u4e49\u89c4\u5219\u3002<\/li>\n<\/ul>\n<p><p>\u56db\u3001 <strong>\u4f7f\u7528\u5185\u5efa\u7f8e\u5316\u529f\u80fd<\/strong><\/p>\n<\/p>\n<p><p>\u867d\u7136Sublime Text 3\u6ca1\u6709\u5185\u7f6e\u4e13\u95e8\u9488\u5bf9PHP\u7684\u683c\u5f0f\u5316\u5de5\u5177\uff0c\u4f46\u5b83\u7684\u4e00\u4e9b\u57fa\u7840\u529f\u80fd\uff0c\u5982<code>Reindent<\/code>\uff0c\u4e5f\u53ef\u4ee5\u8f85\u52a9\u8fdb\u884c\u4ee3\u7801\u6574\u7406\u3002<\/p>\n<\/p>\n<ul>\n<li>\u4f7f\u7528<code>Edit -&gt; Line -&gt; Reindent<\/code>\uff0c\u53ef\u4ee5\u5feb\u901f\u8c03\u6574\u5df2\u9009\u4e2d\u4ee3\u7801\u5757\u7684\u7f29\u8fdb\u3002\u867d\u7136\u8fd9\u4e0d\u662f\u4e13\u95e8\u7684\u683c\u5f0f\u5316\u5de5\u5177\uff0c\u4f46\u5bf9\u4e8e\u7b80\u5355\u7684\u4ee3\u7801\u6574\u7406\u975e\u5e38\u6709\u7528\u3002<\/li>\n<li>\u7ed3\u5408\u4f7f\u7528\u591a\u4e2a\u5185\u5efa\u7f16\u8f91\u529f\u80fd\uff0c\u5982<code>Trim Tr<a href=\"https:\/\/docs.pingcode.com\/blog\/59162.html\" target=\"_blank\">AI<\/a>ling Space<\/code>\u548c<code>Convert Tabs to Spaces<\/code>\uff0c\u53ef\u4ee5\u5728\u4e00\u5b9a\u7a0b\u5ea6\u4e0a\u624b\u52a8\u5b8c\u6210\u4ee3\u7801\u7684\u57fa\u7840\u683c\u5f0f\u5316\u3002<\/li>\n<\/ul>\n<p><p>\u901a\u8fc7\u4e0a\u8ff0\u65b9\u6cd5\uff0cSublime Text 3 \u7528\u6237\u53ef\u4ee5\u6709\u6548\u5730\u683c\u5f0f\u5316PHP\u4ee3\u7801\uff0c\u4e0d\u4ec5\u63d0\u9ad8\u4ee3\u7801\u7684\u6574\u6d01\u6027\u548c\u4e00\u81f4\u6027\uff0c\u8fd8\u80fd\u7b26\u5408\u4e1a\u754c\u7f16\u7801\u6807\u51c6\uff0c\u662f\u63d0\u5347PHP\u5f00\u53d1\u6548\u7387\u548c\u8d28\u91cf\u7684\u91cd\u8981\u624b\u6bb5\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p><strong>\u95ee\uff1asublime text 3\u53ef\u4ee5\u901a\u8fc7\u54ea\u4e9b\u65b9\u5f0f\u6765\u683c\u5f0f\u5316PHP\u4ee3\u7801\uff1f<\/strong><\/p>\n<p>\u7b54\uff1a\u6709\u51e0\u79cd\u65b9\u5f0f\u53ef\u4ee5\u5728sublime text 3\u4e2d\u683c\u5f0f\u5316PHP\u4ee3\u7801\u3002\u9996\u5148\uff0c\u4f60\u53ef\u4ee5\u5b89\u88c5\u4e00\u4e2a\u63d2\u4ef6\uff0c\u4f8b\u5982PHP Coding Standards Fixer\uff0c\u8fd9\u4e2a\u63d2\u4ef6\u53ef\u4ee5\u5e2e\u52a9\u4f60\u81ea\u52a8\u8c03\u6574\u4f60\u7684\u4ee3\u7801\u4ee5\u7b26\u5408PHP\u7f16\u7801\u89c4\u8303\u3002\u5176\u6b21\uff0c\u4f60\u4e5f\u53ef\u4ee5\u4f7f\u7528sublime text\u7684\u5185\u7f6e\u529f\u80fd\uff0c\u901a\u8fc7\u9009\u62e9\u4ee3\u7801\u7247\u6bb5\uff0c\u6309\u4e0b\u5feb\u6377\u952eCtrl + Shift + P\uff0c\u7136\u540e\u5728\u547d\u4ee4\u9762\u677f\u4e2d\u8f93\u5165&quot;reindent&quot;\u6765\u8fdb\u884c\u4ee3\u7801\u91cd\u65b0\u7f29\u8fdb\u3002\u53e6\u5916\uff0csublime text 3\u8fd8\u6709\u8bb8\u591a\u5176\u4ed6\u63d2\u4ef6\u53ef\u4f9b\u9009\u62e9\uff0c\u5b83\u4eec\u63d0\u4f9b\u4e86\u66f4\u591a\u7684\u4ee3\u7801\u683c\u5f0f\u5316\u9009\u9879\uff0c\u4f60\u53ef\u4ee5\u6839\u636e\u81ea\u5df1\u7684\u9700\u6c42\u8fdb\u884c\u9009\u62e9\u548c\u5b89\u88c5\u3002<\/p>\n<p><strong>\u95ee\uff1asublime text 3\u4e2d\u6709\u6ca1\u6709\u5feb\u6377\u952e\u53ef\u4ee5\u5e2e\u52a9\u6211\u683c\u5f0f\u5316PHP\u4ee3\u7801\uff1f<\/strong><\/p>\n<p>\u7b54\uff1a\u662f\u7684\uff0c\u5728sublime text 3\u4e2d\u6709\u4e00\u4e9b\u5feb\u6377\u952e\u53ef\u4ee5\u5e2e\u52a9\u4f60\u683c\u5f0f\u5316PHP\u4ee3\u7801\u3002\u9996\u5148\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528\u5feb\u6377\u952eCtrl + Shift + P\u6765\u6253\u5f00\u547d\u4ee4\u9762\u677f\uff0c\u7136\u540e\u8f93\u5165&quot;reindent&quot;\u6765\u8fdb\u884c\u4ee3\u7801\u91cd\u65b0\u7f29\u8fdb\u3002\u6b64\u5916\uff0c\u4f60\u8fd8\u53ef\u4ee5\u4f7f\u7528\u5feb\u6377\u952eCtrl + K, Ctrl + F\u6765\u683c\u5f0f\u5316\u9009\u4e2d\u7684\u4ee3\u7801\u7247\u6bb5\uff0c\u8fd9\u5c06\u6839\u636esublime text\u7684\u9ed8\u8ba4\u7f29\u8fdb\u8bbe\u7f6e\u8fdb\u884c\u4ee3\u7801\u683c\u5f0f\u5316\u3002\u53e6\u5916\uff0c\u4f60\u4e5f\u53ef\u4ee5\u81ea\u5b9a\u4e49\u5feb\u6377\u952e\u6765\u6267\u884c\u4ee3\u7801\u683c\u5f0f\u5316\u7684\u547d\u4ee4\uff0c\u5177\u4f53\u7684\u6b65\u9aa4\u662f\u5728Preferences -&gt; Keybindings\u4e2d\u6dfb\u52a0\u4e00\u6761\u76f8\u5e94\u7684\u952e\u7ed1\u5b9a\u89c4\u5219\u3002<\/p>\n<p><strong>\u95ee\uff1a\u5982\u4f55\u5728sublime text 3\u4e2d\u8bbe\u7f6ePHP\u4ee3\u7801\u7684\u81ea\u52a8\u683c\u5f0f\u5316\uff1f<\/strong><\/p>\n<p>\u7b54\uff1a\u60f3\u8981\u5728sublime text 3\u4e2d\u5b9e\u73b0\u81ea\u52a8\u683c\u5f0f\u5316PHP\u4ee3\u7801\u7684\u529f\u80fd\uff0c\u4f60\u53ef\u4ee5\u501f\u52a9\u4e00\u4e9b\u63d2\u4ef6\u6765\u5b9e\u73b0\u3002\u9996\u5148\uff0c\u5b89\u88c5\u4e00\u4e2a\u652f\u6301PHP\u4ee3\u7801\u683c\u5f0f\u5316\u7684\u63d2\u4ef6\uff0c\u6bd4\u5982PHP-CS-Fixer\u6216\u8005PHP_CodeSniffer\u3002\u8fd9\u4e9b\u63d2\u4ef6\u53ef\u4ee5\u6839\u636e\u4e00\u4e9b\u9884\u8bbe\u7684\u7f16\u7801\u89c4\u8303\u6765\u8c03\u6574\u4f60\u7684\u4ee3\u7801\uff0c\u5e76\u5728\u4fdd\u5b58\u6587\u4ef6\u65f6\u81ea\u52a8\u8fdb\u884c\u683c\u5f0f\u5316\u3002\u5176\u6b21\uff0c\u4f60\u53ef\u4ee5\u5728sublime text\u7684\u8bbe\u7f6e\u4e2d\u914d\u7f6e\u4e00\u4e2a\u540e\u53f0\u8fdb\u7a0b\uff0c\u8fd0\u884c\u8fd9\u4e9b\u63d2\u4ef6\uff0c\u4ee5\u4fbf\u5b9e\u73b0\u81ea\u52a8\u683c\u5f0f\u5316\u7684\u529f\u80fd\u3002\u5177\u4f53\u7684\u914d\u7f6e\u65b9\u6cd5\u53ef\u4ee5\u901a\u8fc7\u67e5\u9605\u63d2\u4ef6\u7684\u6587\u6863\u6765\u4e86\u89e3\u3002\u53e6\u5916\uff0c\u4f60\u4e5f\u53ef\u4ee5\u4f7f\u7528\u989d\u5916\u7684\u6784\u5efa\u7cfb\u7edf\uff0c\u4f8b\u5982Grunt\u6216Gulp\uff0c\u6765\u5b9e\u73b0\u81ea\u52a8\u5316\u7684\u4ee3\u7801\u683c\u5f0f\u5316\u4efb\u52a1\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"Sublime Text 3 \u683c\u5f0f\u5316PHP\u4ee3\u7801\u53ef\u4ee5\u901a\u8fc7\u5b89\u88c5\u63d2\u4ef6\u3001\u4f7f\u7528\u5185\u5efa\u529f\u80fd\u3001\u4ee5\u53ca\u914d\u5408\u5916\u90e8\u5de5\u5177\u7b49\u65b9\u6cd5\u5b9e\u73b0\u3002\u9996\u5148 [&hellip;]","protected":false},"author":3,"featured_media":181811,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[37],"tags":[],"acf":[],"_links":{"self":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/181793"}],"collection":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/comments?post=181793"}],"version-history":[{"count":0,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/181793\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/181811"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=181793"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=181793"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=181793"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}