Laravel Pint - A PHP Code Style Fixer for Minimalists - TechvBlogs

Laravel Pint - A PHP Code Style Fixer for Minimalists

Laravel Pint is an opinionated PHP code-style fixer for minimalists. Pint is built on top of PHP-CS-Fixer.

Smit Pipaliya - Author - TechvBlogs
Smit Pipaliya

1 month ago

The long-awaited hype train is finally over, Laravel latest open-source CLI app has been released to the world, and we got our hands on it to tell you all about it. Introducing Laravel Pint.

From the readme, "Laravel pint is a zero-dependency PHP code style fixer for minimalists - built on top of PHP-CS-Fixer."

As soon as I read this, I got excited, and I mean very happy. In modern PHP, we have been going through a phase of honing our craft, making our code stricter and better tested, and ensuring we have a consistent code style. This all began back when PHP-FIG was formed, and they started to release PSRs, and it has been going from strength to strength with frameworks having their own specific published style rules. This package is no different and will automatically test and fix your code style based on a preset.


Laravel Pint requires PHP 8.0+.

You may use Composer to install Pint into your PHP project:

#! /bin/bash
composer require laravel/pint --dev

Once Pint has been installed, the pint binary will be available in your project's vendor/bin directory:


Running Pint

When running Pint, it will output a list of files that have been fixed. It is possible to see the changes made in more detail using the -v option:

#! /bin/bash
./vendor/bin/pint -v

In addition, if you would like Pint to inspect your code for style errors without actually changing the files, you may use the --test option:

#! /bin/bash
./vendor/bin/pint --test

Configuring Pint

With our brand new Laravel application, let's configure a preset to Laravel. Create a pint.json file and add:

	"preset": "laravel"

In addition, if you wish to use a pint.json from a specific directory, you may use the --config option:

#! /bin/bash
pint --config vendor/my-company/coding-style/pint.json


Presets defines a set of rules that can be used to fix code style issues in your code. By default, Pint uses the laravel preset, which fixes problems by following the opinionated coding style of Laravel.

However, you can use a different preset by passing the --preset option:

#! /bin/bash
pint --preset psr12

If you wish, you may also set the preset in your project's pint.json file:

	"preset": "psr12"

The currently supported presets are laravel, psr12, and Symfony.


Rules are style guidelines that Pint will use to fix code style issues in your code. As mentioned above, presets are predefined groups of rules that should be perfect for most PHP projects, so you typically will not need to worry about the individual rules they contain.

However, if you wish, you may enable or disable specific rules in your pint.json file:

    "preset": "laravel",
    "rules": {
        "simplified_null_return": true,
        "braces": false,
        "new_with_braces": {
            "anonymous_class": false,
            "named_class": false

Pint is built on top of PHP-CS-Fixer. Therefore, you may use any of its rules to fix code style issues in your project: PHP-CS-Fixer Configurator.

For more details, Visit Github.

Thank you for reading this blog.

Read Also: How To Install Vue 3 in Laravel 9 From Scratch

If you want to manage your VPS / VM Server without touching the command line go and  Checkout this linkServerAvatar allows you to quickly set up WordPress or Custom PHP websites on VPS / VM in a  matter of minutes.  You can host multiple websites on a single VPS / VM, configure SSL certificates, and monitor the health of your server without ever touching the command line interface.

If you have any queries or doubts about this topic please feel free to contact us. We will try to reach you.

Comments (0)

Multiple sites on a single VPS/VM/Server Deploy PHP sites on cloud in minutes, simple as that!
Generate Free SSL Certificate - SSLForWeb

Generate Free SSL Certificate

  • 90-Day Certificates
  • SSL Monitoring
  • Wildcard Certificates
  • Multiple Domains
  • Certificate Management
  • Expiration Reminders


Note: All Input Fields are required.