Skip to main content

Black Friday 2025! Only until December 1st: coupon FRIDAY25 for 40% off Yearly/Lifetime membership!

Read more here
Premium Members Only
Join to unlock this tutorial and all of our courses.
Tutorial Premium Tutorial

Code Styling in Laravel: 11 Common Mistakes

March 17, 2023
7 min read

For fixing code styling mistakes, there's a great tool called Laravel Pint. In this article, I will list one of the most typical fixes it makes, with before/after examples.


1. Unused Imports

Unused imports are one of the most common code style issues in code. This can be caused by copying and pasting some code or simply by refactoring some classes. It usually looks like this:

While my editor marked them as unused - that might not be the case for your editor. That's why Pint has a rule about it:

https://github.com/laravel/pint/blob/main/resources/presets/laravel.php

'no_unused_imports' => true,

And once you run /vendor/bin/pint fix it will remove all unused imports:


2. Function Visibility

Functions in PHP should have their visibility defined even if it's public by default. This is a...

Premium Members Only

This advanced tutorial is available exclusively to Laravel Daily Premium members.

Premium membership includes:

Access to all premium tutorials
Video and Text Courses
Private Discord Channel

Comments & Discussion

SP
Sylvain P ✓ Link copied!

thanks a lot @pav

BM
Briere Mostafa Amine ✓ Link copied!

Thank you.

We'd Love Your Feedback

Tell us what you like or what we can improve

Feel free to share anything you like or dislike about this page or the platform in general.