tightenco/duster
Composer 安装命令:
composer create-project tightenco/duster
包简介
Automatic configuration for Laravel apps to apply Tighten's standard linting & code standards.
README 文档
README
Duster
Automatically apply Tighten's default code style for Laravel apps.
Duster is built on top of the following tools:
- TLint: lints Laravel and PHP code for issues not covered by other tools
- using the default
Tightenpreset
- using the default
- PHP_CodeSniffer: sniffs issues that can't be fixed automatically
- using the
Tightenpreset which is mostly PSR1 with some Tighten-specific rules
- using the
- PHP CS Fixer: adds custom rules not supported by Laravel Pint
CustomOrderedClassElementsFixerTighten-specific order of class elements
- Pint: Laravel's code style rules (with a few Tighten specific customizations)
- using the default
Laravelpreset with some Tighten-specific rules
- using the default
You can view a list of the compiled rules and examples of what they do in the style guide.
Installation
You can install the package via composer:
composer require tightenco/duster --dev
Optionally you can publish a GitHub Actions config:
./vendor/bin/duster github-actions
Or you can publish Husky Hooks:
./vendor/bin/duster husky-hooks
If you are using a containerized environment and do not have PHP installed locally, you can use the --env option to specify it:
./vendor/bin/duster husky-hooks --env=ddev
Supported environments are ddev, warden lando, and sail.
Usage
To lint everything at once:
./vendor/bin/duster lint
To fix everything at once:
./vendor/bin/duster fix
To dust only files that have uncommitted changes according to Git, you may use the --dirty option:
./vendor/bin/duster lint --dirty
#or
./vendor/bin/duster fix --dirty
To view all available commands:
./vendor/bin/duster
#or
./vendor/bin/duster commands
Usage with Sail
./vendor/bin/sail php ./vendor/bin/duster
Alternatively, Sail has a bin script that eases the execution of package binaries, so you do the same thing like this:
./vendor/bin/sail bin duster
Customizing
If you need to include or exclude files or directories for each tool you can create a duster.json config file in your project root:
{
"include": [
"bin",
"scripts",
"src",
"tests"
],
"exclude": [
"tests/fixtures",
"**/folderToExclude/**"
]
}
To run additional scripts as part of Duster first add them to duster.json as part of scripts separated into lint and fix.
The key is the name of the command (used with the --using flag), and the value is an array of arguments passed to Symfony\Component\Process\Process.
{
"scripts": {
"lint": {
"phpstan": ["./vendor/bin/phpstan", "analyse"]
}
},
"processTimeout": 120
}
Duster will pick these up automatically when running either lint or fix.
By default, additional scripts timeout after 60 seconds. You can overwrite this setting using the processTimeout key.
To customize which tools Duster runs, or the order in which they are executed you can use the --using flag and supply a comma-separated list of commands:
./vendor/bin/duster lint --using="phpstan,tlint,pint"
TLint
Create a tlint.json file in your project root. Learn more in the TLint documentation.
PHP_CodeSniffer
Create a .phpcs.xml.dist file in your project root with the following:
<?xml version="1.0"?> <ruleset> <file>app</file> <file>config</file> <file>database</file> <file>public</file> <file>resources</file> <file>routes</file> <file>tests</file> <rule ref="Tighten"/> </ruleset>
Now you can add customizations below the <rule ref="Tighten"/> line or even disable the Tighten rule to use your own ruleset. Learn more in this introductory article.
PHP CS Fixer
Create a .php-cs-fixer.dist.php file in your project root with the contents from Duster's .php-cs-fixer.dist.php file. Learn more in the PHP CS Fixer documentation.
Pint
Create a pint.json file in your project root, you can use Duster's pint.json file as a starting point. Learn more in the Pint documentation.
GitHub Action
There's a GitHub Action you use to clean-up your workflows.
Warning Heads Up! Workflows that commit to your repo will stop any currently running workflows and not trigger another workflow run.
One solution is to run your other workflows after Duster has completed by updating the trigger on those workflows:
on: # Commits made in Duster Fix will not trigger any workflows # This workflow is configured to run after Duster finishes workflow_run: workflows: ["Duster Fix"] types: - completed
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security-related issues, please email hello@tighten.co instead of using the issue tracker.
Credits
- Matt Stauffer
- Anthony Clark
- Tom Witkowski - much of the original idea and syntax for this was inspired by his
elbgoods/ci-test-toolspackage - All Contributors
License
The MIT License (MIT). Please see License File for more information.
tightenco/duster 适用场景与选型建议
tightenco/duster 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2.74M 次下载、GitHub Stars 达 597, 最近一次更新时间为 2021 年 02 月 01 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「php」 「laravel」 「Code style」 「tightenco」 「duster」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 tightenco/duster 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 tightenco/duster 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 tightenco/duster 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Memio's PrettyPrinter, used to generate PHP code from given Model
Promotional Codes Generator for Laravel 5.1
Zend Captcha bundle
Base Skeleton for Laravel Application
Alfabank REST API integration
Statistic of code usage inspired by Laravel Stats
统计信息
- 总下载量: 2.74M
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 597
- 点击次数: 22
- 依赖项目数: 203
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-02-01
