VSCode formatting using "Laravel Blade Formatter" and "PHP Intelephense"

Stefan Bogdanescu

Founder & Senior Architect · 2026-06-29

Laravel Company

Mastering Code Style: Efficiently Switching Between PHP and Blade Formatters in VS Code

As a senior developer working with the Laravel ecosystem, we often rely on specialized tools to ensure code quality. Tools like PHP Intelephense provide unparalleled intelligence for PHP controllers and logic, while extensions like the Laravel Blade Formatter handle the specific syntax and style required for Blade templates. The frustration arises when switching between these context-specific formatters feels like an extra, unnecessary step.

This post dives into how we can streamline this workflow, moving beyond simple manual switching to create a seamless experience within Visual Studio Code by leveraging configuration and extension settings.

The Pain Point: Contextual Formatting Friction

The desire to switch between PHP formatting (for controllers) and Blade formatting (for views) is entirely understandable. Each context demands a different set of stylistic rules—PHP adheres to PSR standards, while Blade follows Laravel's specific templating conventions. When you have to manually select the correct formatter or re-align settings frequently, it creates cognitive overhead and slows down the flow of development.

The core issue isn't necessarily that VS Code cannot switch formatters; it’s that the default behavior often requires manual intervention unless the context is perfectly defined in the workspace settings.

The Efficient Solution: Leveraging VS Code Settings

The most efficient way to manage this dichotomy is by configuring VS Code and your extensions to recognize file types and apply the correct formatting rules automatically based on the file extension. We achieve this by using the editor.defaultFormatter setting in conjunction with language-specific configurations.

1. Defining File-Specific Formatters

Instead of relying on manual selection, we instruct VS Code to use a specific formatter whenever it opens a recognized file type. This is managed within your workspace settings, typically stored in .vscode/settings.json.

For files ending in .php, you would prioritize the configuration linked to PHP Intelephense or whatever tool you designate for controller logic. For .blade.php files, you explicitly set the Laravel Blade Formatter as the default.

Here is an illustrative example of how this setup might look:

{
    // Set defaults based on file extensions
    "[php]": {
        "editor.defaultFormatter": "ms-php.php-formatter" // Example for PHP Intelephense integration
    },
    "[blade]": {
        "editor.defaultFormatter": "laravel.blade-formatter" // Example for the Blade Formatter
    },
    // General formatting settings
    "editor.formatOnSave": true,
    "editor.formatOnType": true
}

By setting these specific overrides, VS Code no longer needs you to manually select the formatter every time you open a .php or .blade.php file; it automatically applies the context-appropriate tool when you save or type. This approach aligns perfectly with the principles of clean, maintainable code that Laravel encourages.

Best Practices for Ecosystem Development

When working within a framework like Laravel, consistency is paramount. Ensuring that your tooling supports this separation helps maintain high standards across the entire codebase. Remember, adherence to conventions—whether structural (PHP) or stylistic (Blade)—is what keeps projects scalable and readable. As we build robust applications on the foundation provided by Laravel, optimizing the development environment is just as important as writing the code itself.

Conclusion: A Seamless Workflow

Switching between specialized formatters efficiently boils down to proactive configuration rather than reactive clicking. By strategically defining file-type-specific defaults in your VS Code settings, you transform a tedious manual task into an automated workflow. This allows you to maintain the high level of style and quality required for professional Laravel development without sacrificing developer time. Embrace configuration as a core part of your development process!