Skip to content

Style guidelines

Kristian Restrepo Osorio edited this page Sep 25, 2024 · 4 revisions

Code Guidelines

Laravel Pint

Laravel Pint is an automatic code formatting and styling tool developed by the Laravel community. It is designed to consistently apply a set of coding style rules to the PHP files in a project, ensuring that the code is readable, maintainable, and adheres to recommended coding standards.

Standards Followed

Laravel Pint is based on PHP-CS-Fixer, a popular PHP code formatter, and it follows the PSR-12 (PHP Standard Recommendation 12) guidelines. This standard is widely accepted in the PHP community and defines how code should be formatted to maintain consistency and clarity. The main rules include:

  • Indentation: Use of 4 spaces for indentation.
  • Line Length: Keeping lines of code to a maximum of 120 characters.
  • Spacing: Spaces around operators, after commas, and around parentheses in control statements.
  • Braces: Consistent placement of opening and closing braces in control statements and functions.
  • Variable Names: Use of camelCase for variable and method names.
  • Namespace and Imports: Consistent and ordered import of namespaces.

Usage

To format the code in the project, Laravel Pint can be run with the following command on the root of the project:

./vendor/bin/pint

Before pushing to the repository, be sure to use the corresponding Laravel pint command to follow the code style.

More information

If you want to know more information about Laravel Pint you can access to its official documentation.

Clone this wiki locally