- How do I install this package for Laravel projects?
- Run `composer require --dev pluswerk/grumphp-bom-task` in your Laravel project. Ensure GrumPHP is installed (`composer require --dev grumphp/grumphp`) as this package extends it. Configure `grumphp.yml` to enable the `plus_bom_fixer` task with your target file types.
- Which Laravel file types should I scan for BOMs?
- Prioritize `config/*.php`, `package.json`, `composer.json`, Blade templates (`.blade.php`), migrations, and SQL files. JSON/YAML configs (e.g., `app/Config/`) are critical—BOMs break parsing. Exclude `vendor/` and `storage/logs/` to avoid false positives.
- Does this work with Laravel’s default PHP 8.x setup?
- Yes. The package supports PHP 7.3+ and GrumPHP v0.16+/v1.x, which aligns with Laravel’s PHP 8.x minimum. No Laravel-specific dependencies exist—it operates at the file level, avoiding framework conflicts.
- Can I integrate this into Laravel’s GitHub Actions CI?
- Absolutely. Add a step to run GrumPHP (e.g., `./vendor/bin/grumphp run`) in your workflow. Place it before tests or deployment to enforce BOM-free files. Example: `uses: actions/checkout@v3` followed by the GrumPHP command.
- What if my team uses Windows-generated files with BOMs?
- Configure `ignore` patterns in `grumphp.yml` to exclude known exceptions (e.g., `legacy/`, `vendor/`). For manual overrides, document a workflow to approve BOM-containing files or use the `aus_bom_fixer` task’s exclusion rules.
- Is this package safe for monorepos with mixed languages?
- Yes. The task targets file extensions (e.g., `php`, `json`, `yml`) via `triggered_by`. Exclude non-text files (e.g., binaries) and configure GrumPHP to run only on relevant directories. Test with your monorepo’s structure to avoid over-scanning.
- How does this differ from running a custom script to strip BOMs?
- This package integrates natively with GrumPHP, offering pre-commit/pre-push enforcement with clear failure messages. Custom scripts lack GrumPHP’s extensibility (e.g., parallel runs, CI hooks) and may miss edge cases like partial BOMs in multi-byte UTF-8 files.
- Will this break existing Laravel deployments?
- No. The package only modifies files during development/pre-commit stages. It won’t alter runtime behavior. Test in staging by running `grumphp run` locally before deployment to catch BOM issues early.
- How do I handle false positives in Laravel’s Blade templates?
- Add Blade files (`.blade.php`) to `triggered_by` in `grumphp.yml` but exclude directories like `resources/views/vendor/`. For templates with legitimate BOMs (rare), use the `ignore` option or document them in a `README` for the team.
- What’s the performance impact of running this in CI?
- Minimal. The task scans files only during GrumPHP execution (not runtime) and supports parallelization. In CI, run it alongside other tasks (e.g., `phpunit`) to avoid bottlenecks. For large repos, limit `triggered_by` to critical file types.