How to override PHPStorm file types

PHPStorm allows you to override the file type, giving you different syntax highlighting and auto-complete prompts.

Joel Clermont
Joel Clermont
2023-09-07

PHPStorm does an excellent job figuring out what type of file you're editing automatically, both by looking at the file's extension and other naming patterns. For example, SomeFile.php will be associated with PHP, but some-view.blade.php will also have extra niceties for Blade enabled.

In yesterday's tip, I talked about how we allow Blade rendering to work inside a Markdown file, but this approach confused PHPStorm a little bit. By default, it treats the file as Markdown, which makes sense since it's a file ending in .md. But then none of the Blade highlighting and auto-complete works. It looks like this

PHPStorm showing file as Markdown

On the other hand, I can right-click the file in PHPStorm's Project view, choose "Override file type" and pick "Blade template" and then it looks like this, giving me a normal Blade experience

PHPStorm showing file as Blade

In the end, I kept it as a normal Markdown file, since we're not using a lot of Blade features, and I can get by just typing out my route helpers without auto-complete. But this can be handy if you ever have a case where the auto-detection isn't doing the thing you want.

Here to help,

Joel

P.S. Laravel is pretty secure by default, but Aaron published a course to go even deeper on Laravel security.

Toss a coin in the jar if you found this helpful.
Want a tip like this in your inbox every weekday? Sign up below 👇🏼

Level up your Laravel skills!

Each 2-minute email has real-world advice you can use.