studio-stomp / craft-twig-linter
A module for Craft CMS bringing `sserbin/twig-linter` to Craft CMS projects
0.6.0
2024-11-18 10:26 UTC
Requires
- php: ^8.2
- ext-json: *
- craftcms/cms: ^4.0|^5.0
- sserbin/twig-linter: ^3.0
Requires (Dev)
- codeception/codeception: ^5.1
- codeception/module-asserts: ^3.0
- codeception/module-yii2: ^1.1
- craftcms/rector: dev-main
- roave/security-advisories: dev-latest
- studio-stomp/phpstan-craftcms: dev-main
- vlucas/phpdotenv: ^5.4
This package is auto-updated.
Last update: 2025-02-18 11:13:00 UTC
README
A module for Craft CMS bringing sserbin/twig-linter
to Craft CMS projects
Requirements
This plugin requires Craft CMS 5.0.0 or later.
Installation
To install the module, follow these instructions.
-
Open your terminal and go to your Craft project:
cd /path/to/project
-
Then tell Composer to load the plugin:
composer require studio-stomp/craft-twig-linter
-
Load the module in the application config:
// File: ./config/app.console.php return [ 'modules' => [ // ... other modules 'craft-twig-linter' => studiostomp\crafttwiglinter\CraftTwigLinter::class ], 'bootstrap' => [ // ... other module ids 'craft-twig-linter' ], ];
Craft Twig Linter Overview
Craft Twig Linter works by:
- Instantiating the Symfony command from
sserbin/twig-linter
- Instantiating a Symfony console app for running the command
- Instantiating a WebApplication for the project (the module runs in context of ConsoleApplication)
- Aggregate all registered Twig extension from both Console and Web (registered by both Craft Plugins and Craft Modules)
- Create a new Twig environment with all the collected extensions
- running the Symfony app
Configuring Craft Twig Linter
Currently, there is no configuration
Using Craft Twig Linter
php craft craft-twig-linter/lint /path/to/templates /path/to/other/templates
Craft Twig Linter Roadmap
Some things to do, and ideas for potential features:
- Make template paths configurable
- Make template paths autodiscoverable
- Make Symfony app independent (PR
sserbin/twig-linter
or fork it) - Make compatible for just Yii2 (if Yii2, does that also cover Craft?)
Brought to you by Studio Stomp