tightenco/duster
Duster automatically applies Tighten’s Laravel code style by running TLint, PHP_CodeSniffer, PHP CS Fixer, and Laravel Pint. Lint or fix the whole project (or only dirty files), and generate GitHub Actions or Husky hooks with optional container env support.
Installation:
composer require tightenco/duster --dev
This installs Duster as a dev dependency, ensuring it’s only used in development environments.
First Run:
./vendor/bin/duster lint
This runs all configured linters (TLint, PHP_CodeSniffer, Pint, and PHP CS Fixer) against your project to check for style violations.
Fix Issues:
./vendor/bin/duster fix
Automatically applies fixable style violations (where supported by the tools).
Check Only Modified Files (Git-aware):
./vendor/bin/duster lint --dirty
Focuses linting on uncommitted changes, speeding up local development workflows.
duster.json: Customize file inclusion/exclusion and add custom scripts.tlint.json (TLint).phpcs.xml.dist (PHP_CodeSniffer).php-cs-fixer.dist.php (PHP CS Fixer)pint.json (Pint)tighten/duster-action for CI integration.Run ./vendor/bin/duster lint in the project root to enforce consistent code standards immediately. Pair with Git hooks (e.g., Husky) to prevent commits with violations:
./vendor/bin/duster husky-hooks
Local Development:
duster husky-hooks to block commits with style issues.
./vendor/bin/duster husky-hooks --env=sail # For Laravel Sail
duster lint in GitHub Actions to fail builds on violations.
- name: Lint Code
uses: tighten/duster-action@v1
with:
command: lint
Team Onboarding:
.php-cs-fixer.dist.php) to the project root.Custom Toolchains:
duster.json to include additional tools (e.g., PHPStan):
{
"scripts": {
"lint": {
"phpstan": ["./vendor/bin/phpstan", "analyse", "--level=5"]
}
}
}
./vendor/bin/duster lint --using="phpstan,tlint,pint"
./vendor/bin/sail bin duster lint
./vendor/bin/duster fix --parallel
duster.json:
{
"exclude": ["tests/fixtures", "storage/framework/**"]
}
Blade File Handling:
.phpcs.xml.dist:
<arg name="exclude" value="resources/views"/>
TLint Fix Failures:
fix command fails if linting finds issues (v3.0+). Use --allow-fix-on-error to bypass:
./vendor/bin/duster fix --allow-fix-on-error
Git Hook Conflicts:
--env to target specific environments:
./vendor/bin/duster husky-hooks --env=ddev
Tool Version Mismatches:
composer require friendsofphp/php-cs-fixer --dev
--verbose to debug tool execution:
./vendor/bin/duster lint --verbose
./vendor/bin/duster lint --dry-run
./vendor/bin/duster lint --using="tlint" > tlint.log
Custom Scripts:
Add scripts to duster.json for tool-agnostic workflows (e.g., security scans):
{
"scripts": {
"lint": {
"security-check": ["./vendor/bin/roave-security-check", "check"]
}
}
}
Tool Ordering:
Override default execution order with --using:
./vendor/bin/duster fix --using="pint,php-cs-fixer,tlint"
Environment Variables: Pass env vars to custom scripts:
{
"scripts": {
"lint": {
"phpstan": ["./vendor/bin/phpstan", "analyse", "--level=5", "--env=testing"]
}
}
}
vendor/, node_modules/). Override in duster.json:
{
"exclude": ["!vendor/bin/duster"] # Re-include Duster itself
}
scripts in duster.json and install it:
composer require --dev phpstan/phpstan
duster lint --dirty before committing to ensure only relevant files are checked.- uses: actions/cache@v3
with:
path: ~/.config/composer/vendor
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
How can I help you explore Laravel packages today?