vincentlanglet/twig-cs-fixer
A coding standards fixer for Twig templates. Analyze and automatically format Twig files with consistent style rules, configurable presets, and CI-friendly checks to keep templates clean and readable across your project.
composer require --dev vincentlanglet/twig-cs-fixervendor/bin/twig-cs-fixer fix templates/base.html.twigvendor/bin/twig-cs-fixer check templates/ — exits with 1 if non-compliantvendor/bin/twig-cs-fixer init to scaffold a .twig-cs-fixer.php config file in your project root — start here to understand defaults and available rulesscripts in composer.json:
{
"scripts": {
"twig:fix": "twig-cs-fixer fix templates/",
"twig:check": "twig-cs-fixer check templates/"
}
}
husky or pre-commit to run twig-cs-fixer check on staged .twig files- run: vendor/bin/twig-cs-fixer check templates/
.twig-cs-fixer.php to enforce shared rules — review diffs to identify style conflicts earlytwig_operator_space, twig_filter_space, twig_indent)autoescape mode in Twig config if using custom escaping strategies — the fixer respects Twig’s escaping context and may misbehave if not aligned--path-mode=override and --allow-risky=yes only after evaluating risk (some rules like twig_tag_syntax may alter semantics if misconfigured)twig_raw_filter or twig_template_syntax rules if using embedded JS/CSS heavily.twig-cs-fixer.php using registerCustomRuleset() or addRule() — for complex legacy templates, start with --verbose to trace rule triggersencoding is set to utf-8 in configHow can I help you explore Laravel packages today?