logo
podcast Podcast
get help Get Unstuck

Make PHPStorm aware of your custom Blade directives

Don't put up with those red squiggly lines

Joel Clermont
Joel Clermont
2024-11-14

Recently I mentioned why you should get rid of the squiggles in your editor.

One error that can be less obvious how to fix is when PHPStorm complains about a custom Blade directive. What can we do in this case?

PHPStorm has support for Blade, and it already knows about all the built-in Blade directives. But a lesser-known feature is that it also allows you to register new directives.

Open up your PHPStorm Settings, then navigate to PHP > Blade and click on the Directives tab.

The simplest approach is just to add the directive without any configuration. This will remove the squiggles and also have it show up in Blade auto-complete.

If you want to get more precise with autocomplete and static analysis, you can also specify parameters and the syntax it will compile to. I typically don't bother with this, but you can look at some existing examples to see how it works.

Here to help,

Joel

P.S. These tips are always published free, so thank you to everyone who bought a copy of our Laravel tips ebook. We appreciate your support!

Toss a coin in the jar if you found this helpful.
Want a tip like this in your inbox every weekday? Sign up below 👇🏼
email
No spam. Only real-world advice you can use.