Giter VIP home page Giter VIP logo

pint's Introduction

Logo Laravel Pint

Overview Laravel Pint

Build Status Total Downloads Latest Stable Version License

Introduction

Laravel Pint is a zero-dependency PHP code style fixer for minimalists - built on top of PHP-CS-Fixer. Pint makes it simple to ensure that your code style stays clean and consistent.

Installation

Laravel Pint requires PHP 8.0+.

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

composer require laravel/pint --dev

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

./vendor/bin/pint

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:

./vendor/bin/pint -v

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

./vendor/bin/pint --test

Configuring Pint

By default, Pint does not require any configuration and will fix code style issues in your code by following the rules defined in the PSR-12 Style Guide.

However, if you wish to customize the presets, rules, or inspected folders, you may do so by creating a pint.json file in your project's root directory:

{
    "preset": "psr12"
}

Presets

Presets define a set of rules that can be used to fix code style issues in your code. By default, Pint uses the psr12 preset, which fixes issues by following the rules defined in the PSR-12 Style Guide.

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

pint --preset laravel

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

{
    "preset": "laravel"
}

The currently supported presets are: psr12, laravel, and symfony.

Rules

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.

Exclude Folders

By default, Pint will inspect all .php files in your project except those in the vendor folder. If you wish to exclude more folders, you may do so by using the exclude configuration option:

{
    "exclude": [
        "my-specific/folder"
    ]
}

Contributing

Thank you for considering contributing to Pint! You can read the contribution guide here.

Code of Conduct

In order to ensure that the Laravel community is welcoming to all, please review and abide by the Code of Conduct.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

License

Pint is open-sourced software licensed under the MIT license.

pint's People

Contributors

nunomaduro avatar jubeki avatar taylorotwell avatar julien-boudry avatar claudiodekker avatar fieu avatar vinkla avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.