Laravel Pro Tips

Laravel Pro Tips

Share this post

Laravel Pro Tips
Laravel Pro Tips
Laravel Code Formatting: 11 Typical Errors to Avoid

Laravel Code Formatting: 11 Typical Errors to Avoid

Laravel Pro Tips's avatar
Laravel Pro Tips
Nov 05, 2023
∙ Paid

Share this post

Laravel Pro Tips
Laravel Pro Tips
Laravel Code Formatting: 11 Typical Errors to Avoid
Share

a broken cell phone with the word error on it
Photo by Kostiantyn Li on Unsplash

1. Removing Unnecessary Imports

It's a common oversight to leave behind unused imports, especially after copying code or making changes to classes. This oversight can be easily addressed as follows:

Set this rule:

'no_unused_imports' => true,

Then, by executing /vendor/bin/pint fix, it will automatically clean up all those redundant imports.


2. Function Visibility Simplified

In PHP, it's essential to specify the visibility of functions, meaning whether a function is public, private, or protected. By default, functions are public, but explicitly defining visibility is considered a best practice in Laravel development.

Rule in Pint Configuration:

This post is for paid subscribers

Already a paid subscriber? Sign in
© 2025 Laravel Pro Tips
Privacy ∙ Terms ∙ Collection notice
Start writingGet the app
Substack is the home for great culture

Share