The bundle ships one console command for setting up configuration when the Symfony Flex recipe is not available.
nowo:twig-inspector:install
Creates the Twig Inspector Bundle configuration file and ensures routes are set up.
php bin/console nowo:twig-inspector:install
What it does
Running this command performs two actions:
- Creates
config/packages/{env}/nowo_twig_inspector.yaml with all available options pre-filled and commented.
- Creates or updates
config/routes.yaml to include the bundle’s route import under when@dev: and when@test:.
If config/routes.yaml already contains an import for NowoTwigInspectorBundle or nowo_twig_inspector, the command skips the route update to avoid duplicates.
When to use it
If you installed the bundle from Packagist and the Symfony Flex recipe ran successfully, you do not need this command — the config and routes files are created automatically during composer require.
Use the install command when:
- Installing from a private Git repository (Flex recipes do not apply to private sources).
- The Flex recipe did not run for any reason and config/routes files are missing.
- You want to regenerate the config file with the full annotated template.
Options
Environment name for which to create the configuration file. Determines the subdirectory: config/packages/{env}/nowo_twig_inspector.yaml.Default: dev# Create config for the test environment
php bin/console nowo:twig-inspector:install --env=test
Overwrite the configuration file if it already exists, without prompting for confirmation. Short alias: -f.php bin/console nowo:twig-inspector:install --force
Interactive behaviour
If the configuration file already exists and --force is not set, the command prompts:
[WARNING] Configuration file already exists: config/packages/dev/nowo_twig_inspector.yaml
Do you want to overwrite it? (yes/no) [no]:
Answer no (or press Enter) to cancel without changes. Answer yes to overwrite.
Examples
Basic setup for dev
php bin/console nowo:twig-inspector:install
Creates config/packages/dev/nowo_twig_inspector.yaml and updates config/routes.yaml.Setup for test environment
php bin/console nowo:twig-inspector:install --env=test
Creates config/packages/test/nowo_twig_inspector.yaml.Force overwrite an existing config
php bin/console nowo:twig-inspector:install --force
Overwrites config/packages/dev/nowo_twig_inspector.yaml without prompting.
Generated config file
The command writes the following fully annotated configuration:
# Twig Inspector Bundle Configuration
# This file was automatically generated by the install command.
# You can modify it according to your needs.
nowo_twig_inspector:
# List of template file extensions to inspect
# Default: ['.html.twig']
enabled_extensions:
- '.html.twig'
# - '.twig'
# - '.xml.twig'
# Templates to exclude from inspection (supports wildcards with *)
excluded_templates:
# - 'admin/*'
# - 'email/*.html.twig'
# - 'security/*'
# Blocks to exclude from inspection (supports wildcards with *)
excluded_blocks:
# - 'javascript'
# - 'head_*'
# - 'styles'
# Enable template usage metrics in Web Profiler
enable_metrics: true
# Custom cookie name for enabling/disabling inspector
cookie_name: 'twig_inspector_is_active'
# Max nesting depth for comment injection (0 = unlimited)
max_injection_depth: 0
# Additional template exclusions
excluded_templates_regex: []
excluded_templates_prefixes: []
# Additional block exclusions
excluded_blocks_regex: []
# Overlay UI
overlay_theme: light
overlay_compact: false
reduced_motion: false
keyboard_shortcut: 'Ctrl+Shift+T'
Generated routes entry
The command appends the following to config/routes.yaml if the import is not already present:
# Twig Inspector Bundle routes (dev and test only — never prod)
when@dev:
nowo_twig_inspector:
resource: '@NowoTwigInspectorBundle/Resources/config/routes.yaml'
when@test:
nowo_twig_inspector:
resource: '@NowoTwigInspectorBundle/Resources/config/routes.yaml'
The bundle works with default values if you later delete the configuration file. The routes file is required for the “open in IDE” links to work.