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.
This will fix the coding style of your project and you’ll see the following output.
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.
Like this article? Consider leaving aTip