artisanpack-ui/code-style-pint
Composer 安装命令:
composer require artisanpack-ui/code-style-pint
包简介
Laravel Pint preset for ArtisanPack UI code standards
README 文档
README
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.
Installation
Install the package via Composer:
composer require artisanpack-ui/code-style-pint --dev
Usage
For Laravel Applications
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
For Laravel Packages
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
WordPress-Style Spacing (Laravel Applications)
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:
- Spaces inside parentheses:
if ( $var )instead ofif ($var) - Spaces inside brackets (variable indices only):
$array[ $key ]instead of$array[$key] - Spaces around concatenation:
$a . $binstead of$a.$b
Note: 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
Running Pint
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
Running PHP-CS-Fixer (WordPress Spacing)
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
Programmatic Configuration
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.
Rules Included
This preset enforces the following code style rules:
- Array Syntax: Short array syntax (
[]instead ofarray()) - Binary Operator Spaces: Single space around operators, aligned assignments
- Brace Position: Same line for control structures, next line for functions
- Class Structure: Ordered class elements (traits, constants, properties, methods)
- Concatenation Spacing: Single space around concatenation operator (
.) - Import Ordering: Alphabetically sorted imports (classes, functions, constants)
- Single Quotes: Single quotes for strings without variables
- Trailing Commas: In multiline arrays, arguments, and parameters
- Visibility Required: All properties, methods, and constants must have visibility
- Yoda Style: Literals on the left side of comparisons
For WordPress-style spacing (spaces inside parentheses and brackets), see the WordPress-Style Spacing section.
Complementary PHPCS Usage
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"
}
}
Recommended Workflow
-
Run Pint first to auto-fix formatting:
./vendor/bin/pint
-
Run PHPCS to catch remaining issues:
./vendor/bin/phpcs --standard=ArtisanPackUIStandard .
Laravel Boost AI Guidelines
This package includes AI guidelines for Laravel Boost, which will automatically be available when users run php artisan boost:install.
Overriding Default Pint Guidelines
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.
Documentation
- Customization Guide - Customize rules and configuration
- Rules Mapping - PHPCS to Pint rule mapping
- IDE Integration - PhpStorm, VS Code, Vim, and more
- CI/CD Integration - GitHub Actions, GitLab CI, and more
- Migration Guide - Migrate from other tools
Contributing
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.
License
This package is open-sourced software licensed under the GPL-3.0-or-later license.
artisanpack-ui/code-style-pint 适用场景与选型建议
artisanpack-ui/code-style-pint 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2.34k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 11 月 21 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「laravel」 「php-cs-fixer」 「code-style」 「Pint」 「artisanpack」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 artisanpack-ui/code-style-pint 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 artisanpack-ui/code-style-pint 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 artisanpack-ui/code-style-pint 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
HiDev plugin for PHP-CS-Fixer
Taptima PHP-CS-Fixer fixers
Axa Zara PHP Code style configuration for `php-cs-fixer` based on PSR-12.
Git hooks for PHP commits QA.
A generic package for implementing Laravel Pint coding standards across Laravel packages
Custom cs-fixer rules
统计信息
- 总下载量: 2.34k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 32
- 依赖项目数: 20
- 推荐数: 0
其他信息
- 授权协议: GPL-3.0-or-later
- 更新时间: 2025-11-21