You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

PhpStorm 2020.3对Blade文件注释异常问题咨询

Fix Blade Block Comment Format in PhpStorm 2020.3

I’ve run into this exact quirk with older PhpStorm versions before—let’s get this sorted out step by step.

First: Ensure PhpStorm Recognizes Your Blade Files

If PhpStorm doesn’t flag your file as a Blade template, it’ll default to HTML comments automatically. Here’s how to confirm the file association:

  • Open Settings (File > Settings on Windows/Linux, Cmd+, on Mac, or use the shortcut Ctrl+Alt+S)
  • Navigate to Editor > File Types
  • Scroll to find Blade under the PHP category
  • Check if *.blade.php is listed in the Registered Patterns section. If not, click the + button, paste *.blade.php into the field, and save your changes.

Option 1: Use the Context-Aware Comment Shortcut

Once your files are properly associated, PhpStorm should switch comment styles based on the file type. Give this a try:

  • Select the text you want to comment out
  • Press Ctrl+/ (Windows/Linux) or Cmd+/ (Mac) twice:
    • The first press adds line-by-line Blade comments ({{-- ... --}} per line)
    • The second press wraps the entire selection in a single Blade block comment {{-- ... --}}

If this still defaults to HTML comments, move on to the reliable live template workaround below.

Option 2: Create a Blade Block Comment Live Template

This is a foolproof way to force the correct comment syntax whenever you need it:

  • Go back to Settings, then head to Editor > Live Templates
  • Click the + button at the top, choose Template Group, name it something like Blade Custom, and hit OK
  • Select your new group, click + again, choose Live Template
  • Fill in these details:
    • Abbreviation: bcom (or any shorthand you prefer)
    • Template Text: {{-- $SELECTION$ --}}
    • Description: Blade Block Comment
  • Click the Define button under Applicable Contexts, check Blade under the PHP section, then save
  • Now, select your target text, type bcom, and press Tab—it’ll instantly wrap the selection in the correct Blade comment syntax.

Quick note: If you’re editing a pure HTML section in your Blade file, PhpStorm might still default to HTML comments. In that case, use the live template to force the Blade comment style.

内容的提问来源于stack exchange,提问作者Jorge Peralta

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.11 08:12:39