DEV Community

Cover image for Ensure a beaut code with Laravel Pint
David Silva
David Silva

Posted on

2

Ensure a beaut code with Laravel Pint

Hello,

This is my first full English post! So, I'd starting with "sorry" for my wrongs, I'm learning :)

If you, like me, has Laravel inside your world and like beautiful things, I think you need to meet the Laravel Pint.

Laravel Pint help us to keep a good code style.

Working in one team without some code styler or some texteditor settings, usually we need to check a lot of spaces changes, breaklines, positions in the Pull Request review. It's so bad and sad to review one big PR with a lot of 'non-necessary-changes'.

To solve this, we can setup the default code style for everyone of the time, this make more easy to check codes from other person and improve the PR Review moments.

With Laravel Pint is so easy setup a one default way to this, without extra settings like with pure PHP-CS.

Let's install de Pint with the normal command:

composer require laravel/pint --dev
Enter fullscreen mode Exit fullscreen mode

After installation, you can just run:

./vendor/bin/pint 
Enter fullscreen mode Exit fullscreen mode

At the first time, you can see a lot of files changes, like in this my personal hobby project:

Changes after run command

Of course, in this simple way, you will need run the command before commits to ensure a correct code style. We can improve this we can to use some pre-commit hook, like a grumphp https://github.com/phpro/grumphp.

In other post, I can write more about grumphp, but if you want, you can check the oficial docs to learn more.

For today it's only, thanks for read! :)

Sentry blog image

How I fixed 20 seconds of lag for every user in just 20 minutes.

Our AI agent was running 10-20 seconds slower than it should, impacting both our own developers and our early adopters. See how I used Sentry Profiling to fix it in record time.

Read more

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay