Laravel uses .stub files for generating code.
By default, PhpStorm doesn't treat them as PHP.
This means you don't get any syntax highlighting, code completion, or error detection.
Here's how to fix it:
- Right-click the
.stubfile in the project explorer. - Choose "Override File Type..."
- In the dialog that appears, select "PHP"
This will tell PhpStorm to treat just this one stub file as PHP, not all stub files. Repeat the process for any other stub files you want to edit with full PHP syntax support.
This is especially useful when customizing Laravel's default stubs (php artisan stub:publish) or one of your package's stubs.
It's not something I need every day, but these small quality of life improvements make editing stubs much more pleasant when I need it.
Here to help,
Joel
P.S. Do you have a tip to share for your favorite editor? This would be a great thing to bring to our monthly community dev call.