Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Twig Cs Fixer

Twig Cs Fixer Laravel Package

vincentlanglet/twig-cs-fixer

A PHP tool that lints and automatically fixes Twig templates against the official Twig coding standards. Install it via Composer or as a PHAR and run lint or fix commands on any directory, with support for custom and node-based rules.

View on GitHub
Deep Wiki
Context7

A tool to automatically fix Twig Coding Standards issues

Frequently asked questions about Twig Cs Fixer
Does Twig CS Fixer work with Laravel?
It works with Laravel only if your application actually renders Twig templates, for example through TwigBridge. It is not a Blade formatter and will not lint or fix Blade files. For a pure Laravel and Blade stack, use Laravel Pint and Blade-focused tooling instead.
How do I install Twig CS Fixer with Composer?
Run composer require --dev vincentlanglet/twig-cs-fixer to add it as a development dependency. Then invoke vendor/bin/twig-cs-fixer lint /path/to/code or vendor/bin/twig-cs-fixer fix /path/to/code. Composer installation is recommended because it autoloads everything needed for node-based and custom rules.
What is the difference between twig-cs-fixer lint and fix?
The lint command detects coding standard violations and reports them without modifying your templates. The fix command applies automatic corrections to the affected files. Run lint first to measure your baseline, then apply fixes in isolated pull requests so formatting changes stay separate from functional work.
Can I use Twig CS Fixer as a PHAR instead of Composer?
Yes, signed PHAR archives are available from the GitHub releases page for each VERSION. This is useful when Composer dependency conflicts make a dev dependency difficult in constrained CI images. If you need node-based or custom rules with the PHAR, require your project vendor autoload file in the configuration.
Which PHP and Twig versions are supported by Twig CS Fixer?
Check the Packagist page and the release notes for the current PHP and Twig support matrix before pinning a version. The 4.x line introduced backward-compatible breaks in rule and token APIs, so review major upgrades carefully. Pin the package in your lockfile and test upgrades against your template inventory.
How do I configure custom rules or node-based rules in Twig CS Fixer?
The configuration file supports standards, rule selection, ignored violations, and custom rules. To use node-based rules from existing PHP tooling or to write your own rules, add require_once __DIR__.'/vendor/autoload.php' to the config file. This gives the tool access to Composer autoloading for those rule classes.
Can Twig CS Fixer run in CI such as GitHub Actions or GitLab?
Yes, it is designed to be CI-ready and produces clear, actionable reports from the lint command. You can start with an advisory gate or restrict checks to changed files before enforcing a full-repository requirement. Decide whether auto-fix is allowed on feature branches or only through dedicated formatting pull requests.
Is it safe to auto-fix Twig templates with Twig CS Fixer?
Formatting rules should be semantically neutral, but whitespace-control syntax, comments, and custom Twig extensions still deserve review. Run lint first and apply fix in isolated pull requests so template behavior changes are easy to inspect. The tool operates on template source files and has no production request-path impact.
How does Twig CS Fixer compare to PHP CS Fixer or Laravel Pint?
It coexists with PHP linters and formatters rather than replacing them. PHP CS Fixer and Laravel Pint handle PHP code, while Twig CS Fixer handles Twig template coding standards. It does not solve Blade, HTML, JavaScript, or CSS formatting, so keep ownership of each file type separate.
What are the adoption risks of using Twig CS Fixer?
Adoption signals are modest, with roughly 357 stars and no dependents, and the project has a single-maintainer risk profile. The 4.x series introduced backward-compatible breaks, and Twig syntax evolution can expose tokenizer or rule gaps. It is dev-only and offers a signed PHAR, but you should pin versions via lockfile and monitor advisories.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
dbravoan/dbcms-admin-theme-dbcms
dbravoan/dbcms-theme-db-cyber
dbravoan/dbcms-blocks-basic
dbravoan/dbcms-module-content-audit
dbravoan/dbcms-module-ai-assistant
paygate-to/paygate-php
padosoft/askmydocs-connector-base
defstudio/supercharged-carbon
bernskioldmedia/laravel-matomo
bernskioldmedia/laravel-harvest
bernskiold/laravel-data-scrubber
bernskiold/laravel-currency-converter
bernskiold/laravel-campaign-monitor
bernskioldmedia/laravel-autotranslate
siberfx/telegram-bot
roy-sandip/laravel-view-extended
gregsphotography/site-builder-core
roy-sandip/laravel-view
anodyne/blade-fluentui-icons
webx-ui/module-catalog-collections