- How do I install Duster in a Laravel project?
- Run `composer require tightenco/duster --dev` to install Duster. No additional Laravel service provider or configuration is needed—it integrates directly via Composer’s bin directory. For GitHub Actions or Husky hooks, use `./vendor/bin/duster github-actions` or `./vendor/bin/duster husky-hooks` after installation.
- Does Duster work with Laravel Sail?
- Yes, Duster supports Laravel Sail natively. Execute it via `./vendor/bin/sail bin duster` or `./vendor/bin/sail php ./vendor/bin/duster` to run linting or fixes inside your Sail container. The `--env=sail` flag also works for containerized environments.
- Can I customize which files or directories Duster scans?
- Absolutely. Create a `duster.json` file in your project root to define `include` and `exclude` patterns. For example, exclude tests or include custom directories like `bin` or `scripts`. This overrides Duster’s default Laravel-focused paths.
- What Laravel versions does Duster support?
- Duster is optimized for Laravel 8+ and requires PHP 8.0+. It leverages Laravel Pint (built into Laravel 9+) and integrates with Laravel’s ecosystem tools like TLint and PHP_CodeSniffer, which are version-agnostic but best suited for modern Laravel projects.
- How do I run Duster only on changed files (like `--dirty` in Git)?
- Use the `--dirty` flag with `lint` or `fix` commands, e.g., `./vendor/bin/duster lint --dirty`. This runs Duster only on uncommitted Git changes, making it ideal for pre-commit hooks or CI workflows to avoid unnecessary full-project scans.
- What if my team uses different coding standards than Tighten’s?
- Duster’s `duster.json` lets you override defaults, but its core tools (TLint, PHPCS, Pint) are opinionated. For non-Tighten standards, consider alternatives like custom PHPCS rules or Laravel Pint alone. Refactoring existing code to match Tighten’s rules may require manual adjustments or a phased rollout.
- Will Duster slow down my CI/CD pipeline?
- Duster runs multiple tools sequentially by default, which can add overhead. Mitigate this by using `--dirty` for PR checks or running tools in parallel (e.g., PHP CS Fixer and Pint concurrently). For large codebases, start with `lint --dirty` to avoid blocking merges.
- How do I integrate Duster with GitHub Actions?
- Publish the workflow config with `./vendor/bin/duster github-actions`. This generates a `.github/workflows/duster.yml` file that runs linting and fixing on push/PR events. Customize the workflow by editing the generated file or using the `--env` flag for containerized runners like Sail.
- Does Duster support Husky for local pre-commit hooks?
- Yes, run `./vendor/bin/duster husky-hooks` to generate Husky pre-commit hooks. These hooks will automatically run Duster’s `lint --dirty` before commits. Specify your container environment (e.g., `--env=sail`) if running locally in a containerized setup.
- What’s the difference between `duster lint` and `duster fix`?
- `duster lint` checks code against Tighten’s standards and reports issues without modifying files. `duster fix` applies automatic fixes (e.g., via PHP CS Fixer or Pint) where possible. Use `fix` cautiously in shared environments, as it modifies files directly.