artisanpack-ui/code-style-pint
Laravel Pint preset matching ArtisanPack UI coding standards. Publishes a ready-made pint.json for apps or generates it via builder for packages. Optional WordPress-style spacing support via PHP-CS-Fixer stubs and commands.
This guide helps you migrate to the ArtisanPack UI code style using Laravel Pint.
If you're not currently using any code style tool:
composer require artisanpack-ui/code-style-pint --dev
php artisan artisanpack:publish-pint-config
First, see what changes Pint would make:
./vendor/bin/pint --test
Then apply the fixes:
./vendor/bin/pint
Review the changes before committing:
git diff
For large codebases, consider committing in stages:
# First commit: formatting changes only
./vendor/bin/pint
git add -A
git commit -m "style: apply ArtisanPack UI code style"
If you're migrating from PHP-CS-Fixer:
composer require artisanpack-ui/code-style-pint --dev
cp .php-cs-fixer.php .php-cs-fixer.php.backup
cp .php-cs-fixer.dist.php .php-cs-fixer.dist.php.backup # if exists
php artisan artisanpack:publish-pint-config
Review differences between your PHP-CS-Fixer config and the Pint preset. Key mappings:
| PHP-CS-Fixer | Pint (ArtisanPack UI) |
|---|---|
[@PSR12](https://github.com/PSR12) |
preset: laravel |
array_syntax |
array_syntax |
binary_operator_spaces |
binary_operator_spaces |
braces |
braces_position |
ordered_imports |
ordered_imports |
single_quote |
single_quote |
yoda_style |
yoda_style |
If you have custom rules in .php-cs-fixer.php, add them to pint.json:
// Old .php-cs-fixer.php
return (new PhpCsFixer\Config())
->setRules([
'concat_space' => ['spacing' => 'one'],
'blank_line_before_statement' => ['statements' => ['return']],
]);
// New pint.json (add to existing rules)
{
"rules": {
"concat_space": { "spacing": "one" },
"blank_line_before_statement": { "statements": ["return"] }
}
}
./vendor/bin/pint
composer remove friendsofphp/php-cs-fixer
rm .php-cs-fixer.php .php-cs-fixer.dist.php .php-cs-fixer.cache
If you're using Laravel's default Pint configuration:
composer require artisanpack-ui/code-style-pint --dev
cp pint.json pint.json.backup # if exists
php artisan artisanpack:publish-pint-config --force
The ArtisanPack UI preset differs from Laravel's default in these areas:
| Rule | Laravel Default | ArtisanPack UI |
|---|---|---|
binary_operator_spaces |
single_space |
Aligned = and => |
braces_position (functions) |
same_line |
next_line_unless_newline_at_signature_end |
yoda_style |
false |
true for equal and identical |
declare_strict_types |
Not enforced | true |
void_return |
Not enforced | true |
./vendor/bin/pint
If you're using only artisanpack-ui/code-style (PHPCS):
composer require artisanpack-ui/code-style-pint --dev
php artisan artisanpack:publish-pint-config
Change your workflow to run Pint before PHPCS:
# Auto-fix with Pint
./vendor/bin/pint
# Then check remaining issues with PHPCS
./vendor/bin/phpcs --standard=ArtisanPackUIStandard .
PHPCS is still needed for:
See Rules Mapping for details on which rules require PHPCS.
For large projects, consider a gradual migration:
# Week 1: Format app/Models
./vendor/bin/pint app/Models
# Week 2: Format app/Http/Controllers
./vendor/bin/pint app/Http/Controllers
# Week 3: Format remaining directories
./vendor/bin/pint
Start with a minimal configuration and add rules gradually:
// Week 1: Basic formatting
{
"preset": "laravel",
"rules": {
"array_syntax": { "syntax": "short" },
"single_quote": true
}
}
// Week 2: Add structure rules
{
"preset": "laravel",
"rules": {
"array_syntax": { "syntax": "short" },
"single_quote": true,
"ordered_imports": {
"sort_algorithm": "alpha",
"imports_order": ["class", "function", "const"]
}
}
}
// Week 3: Full preset
// Run: php artisan artisanpack:publish-pint-config --force
{
"preset": "laravel",
"rules": { ... },
"exclude": [
"app/Legacy",
"app/OldModules"
]
}
git checkout -b style/apply-artisanpack-ui-code-style
./vendor/bin/pint
git add -A
git commit -m "style: apply ArtisanPack UI code style"
git push origin style/apply-artisanpack-ui-code-style
# Commit 1: Models
./vendor/bin/pint app/Models
git add app/Models && git commit -m "style: format Models"
# Commit 2: Controllers
./vendor/bin/pint app/Http/Controllers
git add app/Http/Controllers && git commit -m "style: format Controllers"
# Continue for other directories...
If certain rules cause too many changes, disable them initially. See Customization Guide for details.
use ArtisanPackUI\CodeStylePint\Config\PintConfigBuilder;
PintConfigBuilder::create()
->withArtisanPackUIPreset()
->removeRule('yoda_style') // Disable Yoda conditions
->removeRule('declare_strict_types') // Disable strict types
->addRule('binary_operator_spaces', [
'default' => 'single_space', // Disable alignment
])
->save(base_path('pint.json'));
After migration, verify everything works:
# 1. Run tests
./vendor/bin/pest
# or
./vendor/bin/phpunit
# 2. Run Pint in test mode
./vendor/bin/pint --test
# 3. Run PHPCS
./vendor/bin/phpcs --standard=ArtisanPackUIStandard .
# 4. Run static analysis if available
./vendor/bin/phpstan analyse
If issues arise:
# Restore backup
cp pint.json.backup pint.json
# Or reset changes
git checkout -- .
# Or revert commit
git revert HEAD
If you encounter issues during migration:
How can I help you explore Laravel packages today?