noop's avatar
Level 5

How to get suggestions on VS Code / Cursor inside blade files

Usually, I use PHPStorm with Laravel Idea, but I’m trying out Cursor IDE, and I’m really missing the suggestions from PHPStorm, especially features like this:

PHPStorm Suggestions
PHPStorm Blade File Suggestions

How can I get something similar in VS Code?

0 likes
1 reply
LaryAI's avatar
Level 58

To get similar suggestions and autocompletion features in VS Code for Laravel Blade files, you can use a combination of extensions and settings. Here’s a step-by-step guide to set it up:

  1. Install the necessary extensions:

    • Laravel Blade Snippets: This extension provides Blade syntax highlighting and snippets.
    • Laravel Extra Intellisense: This extension offers additional IntelliSense for Laravel projects.
    • PHP Intelephense: A powerful PHP language server that provides advanced features like autocompletion, go to definition, and more.

    You can install these extensions from the VS Code marketplace. Simply search for them in the Extensions view (Ctrl+Shift+X).

  2. Configure PHP Intelephense:

    After installing PHP Intelephense, you might need to configure it to work well with Laravel. Add the following settings to your settings.json file:

    {
      "intelephense.files.associations": [
        "*.php",
        "*.phtml",
        "*.module",
        "*.inc",
        "*.blade.php"
      ],
      "intelephense.environment.includePaths": [
        "vendor"
      ]
    }
    
  3. Enable Blade syntax highlighting and snippets:

    The Laravel Blade Snippets extension should automatically provide syntax highlighting and snippets for Blade files. If it doesn’t, ensure that your Blade files have the .blade.php extension.

  4. Additional settings for better experience:

    You can also add some additional settings to improve your development experience:

    {
      "editor.quickSuggestions": {
        "other": true,
        "comments": false,
        "strings": true
      },
      "editor.suggestSelection": "first",
      "php.suggest.basic": false,
      "blade.format.enable": true,
      "blade.format.wrapLineLength": 120,
      "blade.format.wrapAttributes": "auto"
    }
    
  5. Restart VS Code:

    After installing the extensions and updating the settings, restart VS Code to ensure all changes take effect.

By following these steps, you should be able to get similar suggestions and autocompletion features in VS Code for your Laravel Blade files, making your development experience closer to what you are used to in PHPStorm.

If you have any further questions or need additional help, feel free to ask!

Please or to participate in this conversation.