friendsoftwig/twigcs
Twigcs is a checkstyle/linter for Twig templates, like phpcs for PHP. Scan template directories for coding standard violations, control exit codes via severity, and exclude paths. Install via Composer or PHIVE and run as a CLI tool.
twigcs remains a Twig-specific linter/validator, maintaining its seamless fit for Laravel/PHP projects using Twig (standalone or via TwigBridge). The new release does not introduce architectural changes that would alter this fit.Application::add() method) ensures compatibility with modern Symfony/Laravel stacks using newer Symfony components (e.g., Laravel 10+ with Symfony 6.4+)..twigcs.yml or rule customization capabilities.symfony/console.
symfony/console:^6.0 in composer.json if using Laravel <10 or Symfony <8.0.twiglint, phpstan)..twigcs.yml remains necessary.symfony/console:^6.0 to avoid warnings.symfony/console pinned..twigcs.yml?symfony/console:^6.0 to avoid deprecation warnings.twigcs check --dry-run to identify issues.composer.json:
"require-dev": {
"friendsoftwig/twigcs": "^6.6.1",
"symfony/console": "^6.0" // Only if using Symfony Console <8.0
}
.twigcs.yml with defaults..github/workflows/lint.yml:
- name: Twig Lint
run: vendor/bin/twigcs check --format=json > twigcs.json
^6.0 for older versions).symfony/console to ^6.0 if using <8.0 (before integrating twigcs)..twigcs.yml as needed.symfony/console if using versions <8.0:
"require-dev": {
"symfony/console": "^6.0"
}
twigcs to ^6.6.1 in composer.json.--verbose for details; check GitHub issues.symfony/console is updated.| Failure Type | Impact | Mitigation |
|---|---|---|
| False Positives | Developer friction. | Start with --allow-risky; refine rules. |
| Blade Parsing Errors | CI failures. | Exclude Blade or pre-process. |
| Symfony Console Warnings | Deprecation logs (non-breaking). | Pin symfony/console:^6.0 if <8.0. |
| Rule Breaking Changes | Build failures. | Pin twigcs version; test upgrades. |
| CI Timeout | Blocked pipelines. | Cache results; run in parallel. |
.twigcs.yml examples.twigcs.How can I help you explore Laravel packages today?