A Composer package for implementing Laravel Pint coding standards across Laravel packages.
This package provides:
- A standardised
pint.jsonconfiguration file with PSR-12 preset and custom rules - Shell scripts to run Laravel Pint for code formatting and testing
- Automatic Laravel Pint dependency management through Composer
Install the package using Composer:
composer require synergitech/laravel-coding-standards --devThis will automatically install Laravel Pint as a dependency and make the scripts available in your project.
-
As a Git Submodule:
git submodule add https://github.com/SynergiTech/laravel-coding-standards.git tools/coding-standards
-
Manual Installation: Copy the files directly to your project and install Laravel Pint separately:
composer require laravel/pint --dev
To automatically fix coding standard issues:
./vendor/synergitech/laravel-coding-standards/pintOr if installed as submodule/manually:
./tools/coding-standards/pint
# or
./pintYou can pass additional arguments to customise the behaviour:
./vendor/synergitech/laravel-coding-standards/pint --verbose
./vendor/synergitech/laravel-coding-standards/pint --dry-run
./vendor/synergitech/laravel-coding-standards/pint app/ModelsTo check for coding standard issues without making changes:
./vendor/synergitech/laravel-coding-standards/pint-testOr if installed as submodule/manually:
./tools/coding-standards/pint-test
# or
./pint-testYou can pass additional arguments to customise the testing:
./vendor/synergitech/laravel-coding-standards/pint-test --verbose
./vendor/synergitech/laravel-coding-standards/pint-test app/ControllersFor easier access, you can add these scripts to your project's composer.json:
{
"scripts": {
"pint": "./vendor/synergitech/laravel-coding-standards/pint",
"pint:test": "./vendor/synergitech/laravel-coding-standards/pint-test"
}
}Then run:
composer run pint # Apply formatting
composer run pint:test # Test standardsAs this plugin acts as a wrapper for pint, the boost guidelines that get published into the project do not reference this package.
If you use boost then you will need to override the boost guidelines for pint.
If you want this package to publish boost guideline stubs into your project (.ai/guidelines), add the Composer install script override below to your project's composer.json:
{
"scripts": {
"post-install-cmd": [
"SynergiTech\\LaravelCodingStandards\\ComposerScripts::publishGuidelines"
]
}
}After adding it, run:
composer installThis triggers SynergiTech\LaravelCodingStandards\ComposerScripts::publishGuidelines and copies the guideline files into .ai/guidelines which boost will interpret as an overwrite when running boost:install and boost:update.
The pint.json file includes:
- PSR-12 preset as the base standard
- Custom rules for enhanced code quality
- Exclusion of common directories (vendor, storage, bootstrap/cache)
- Array syntax and indentation improvements
- Multiline comment alignment
- String concatenation with single space
- Strict type comparisons
- Ordered class elements and imports
- Modern PHP syntax preferences
- And many more quality-of-life improvements
For a full list of rules, see the pint.json configuration file.
- PHP ^8.1
- Laravel Pint ^1.0 (automatically installed with this package)
This package is open-sourced software licensed under the MIT license.