Get "PHP 8 in a Nuthshell" (Now with PHP 8.4)
Amit Merchant

Amit Merchant

A blog on PHP, JavaScript, and more

Using PER Coding Style with Laravel Pint

The latest coding standard for PHP

When it comes to using a clean and consistent coding style across your Laravel project, the best way to do this is by using the Laravel Pint package. It’s a package that allows you to use the standard PSR coding style in your Laravel project.

Using Laravel Pint

To use the Laravel Pint package, you need to install it via Composer.

$ composer require --dev laravel/pint

Once done, you can run the pint command to fix the coding style of your project like so.

$ ./vendor/bin/pint

This will fix the coding style of your project and you’ll see the following output.

Laravel Pint with Laravel preset

As you can tell, by default, the Laravel Pint package uses the LARAVEL preset to fix the coding style of your project which under the hood uses the PSR-12 coding style.

The PER Coding Style

But recently, the Laravel Pint package has added support for the new PER coding style as well. The PER coding style essentially expands on the PSR-12 coding style and adds a few more rules to it and replaces the PSR-12 coding style altogether.

So, if you want to use the PER coding style, you can do so by passing the --preset=per option to the pint command like so.

$ ./vendor/bin/pint --preset=per

This will fix the coding style of your project using the PER coding style and you’ll see the following output.

Laravel Pint PER

Learn the fundamentals of PHP 8 (including 8.1, 8.2, and 8.3), the latest version of PHP, and how to use it today with my new book PHP 8 in a Nutshell. It's a no-fluff and easy-to-digest guide to the latest features and nitty-gritty details of PHP 8. So, if you're looking for a quick and easy way to PHP 8, this is the book for you.

Like this article?

Buy me a coffee

👋 Hi there! I'm Amit. I write articles about all things web development. You can become a sponsor on my blog to help me continue my writing journey and get your brand in front of thousands of eyes.

Comments?