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.
Laravel Pint preset for ArtisanPack UI code standards. This package provides a pre-configured pint.json file that enforces coding standards matching the artisanpack-ui/code-style PHPCS package.
Install the package via Composer:
composer require artisanpack-ui/code-style-pint --dev
Publish the pint.json configuration file to your project root:
php artisan artisanpack:publish-pint-config
Use --force to overwrite an existing pint.json:
php artisan artisanpack:publish-pint-config --force
Alternatively, use Laravel's standard publish command:
php artisan vendor:publish --tag=artisanpack-pint-config
When developing a Laravel package, use PintConfigBuilder directly since php artisan isn't available:
Standard Pint Configuration:
<?php
// pint-setup.php
require __DIR__ . '/vendor/autoload.php';
use ArtisanPackUI\CodeStylePint\Config\PintConfigBuilder;
PintConfigBuilder::create()
->withArtisanPackUIPreset()
->save(__DIR__ . '/pint.json');
Run it once to generate your config:
php pint-setup.php
Or copy the stub directly:
cp vendor/artisanpack-ui/code-style-pint/stubs/pint.json.stub pint.json
WordPress-Style Spacing (PHP-CS-Fixer):
For WordPress-style spacing in packages, copy the PHP-CS-Fixer configuration stub:
cp vendor/artisanpack-ui/code-style-pint/stubs/.php-cs-fixer.dist.php.stub .php-cs-fixer.dist.php
Then install PHP-CS-Fixer:
composer require --dev friendsofphp/php-cs-fixer
If you need WordPress-style spacing (spaces inside parentheses and brackets) in a Laravel application, use the --wordpress flag:
php artisan artisanpack:publish-pint-config --wordpress
This will create .php-cs-fixer.dist.php with custom fixers that enforce:
if ( $var ) instead of if ($var)$array[ $key ] instead of $array[$key]$a . $b instead of $a.$bNote: WordPress spacing requires PHP-CS-Fixer instead of Pint:
# Install PHP-CS-Fixer
composer require --dev friendsofphp/php-cs-fixer
# Run code formatting
./vendor/bin/php-cs-fixer fix
Once the Pint configuration is in place, run Pint to format your code:
./vendor/bin/pint
To test without making changes:
./vendor/bin/pint --test
If you're using WordPress-style spacing, run PHP-CS-Fixer instead:
./vendor/bin/php-cs-fixer fix
To test without making changes:
./vendor/bin/php-cs-fixer fix --dry-run --diff
For advanced use cases, you can build configurations programmatically:
use ArtisanPackUI\CodeStylePint\Config\PintConfigBuilder;
// Full preset (use base_path() in Laravel apps, __DIR__ in packages)
PintConfigBuilder::create()
->withArtisanPackUIPreset()
->save(__DIR__ . '/pint.json');
// Customize rule groups
PintConfigBuilder::create()
->withFormattingRules(true)
->withCodeStructureRules(true)
->withBestPracticeRules(false) // Disable strict types, yoda style, etc.
->withArtisanPackUIPreset()
->addRule('concat_space', ['spacing' => 'one'])
->removeRule('yoda_style')
->exclude('tests/fixtures')
->save(__DIR__ . '/pint.json');
See docs/customization.md for detailed customization options.
This preset enforces the following code style rules:
[] instead of array()). )For WordPress-style spacing (spaces inside parentheses and brackets), see the WordPress-Style Spacing section.
Some rules cannot be enforced by Pint (security checks, naming conventions, line length). For complete code style enforcement, use both packages:
{
"require-dev": {
"artisanpack-ui/code-style": "^1.0",
"artisanpack-ui/code-style-pint": "^1.0"
}
}
Run Pint first to auto-fix formatting:
./vendor/bin/pint
Run PHPCS to catch remaining issues:
./vendor/bin/phpcs --standard=ArtisanPackUIStandard .
This package includes AI guidelines for Laravel Boost, which will automatically be available when users run php artisan boost:install.
To have AI assistants use ArtisanPack UI standards instead of Laravel's default Pint guidelines, publish the Boost override:
php artisan vendor:publish --tag=artisanpack-boost-override
This creates .ai/guidelines/laravel/pint.blade.php, which overrides Boost's default Pint guidelines with ArtisanPack UI specific guidance.
As an open source project, this package is open to contributions from anyone. Please read through the contributing guidelines to learn more about how you can contribute to this project.
This package is open-sourced software licensed under the GPL-3.0-or-later license.
How can I help you explore Laravel packages today?