Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/nowo-tech/TwigInspectorBundle/llms.txt

Use this file to discover all available pages before exploring further.

How configuration is created

The bundle alias is nowo_twig_inspector. Symfony automatically loads any config file that matches this alias:
  • config/packages/nowo_twig_inspector.yaml (all environments)
  • config/packages/dev/nowo_twig_inspector.yaml (dev only)
Symfony Flex (Packagist install) creates the config and routes files automatically — no manual step needed. Git or private repo install — run the install command:
php bin/console nowo:twig-inspector:install
This creates config/packages/dev/nowo_twig_inspector.yaml and updates config/routes.yaml. Use --force to overwrite an existing config file, and --env=test for the test environment.
The bundle works without any config file. All options fall back to their defaults from Configuration.php when no YAML is present.

Config options reference

enabled_extensions
array
default:"['.html.twig']"
Template file extensions the inspector instruments. Add .twig if you use bare Twig files.
enabled_extensions:
    - '.html.twig'
    - '.twig'
excluded_templates
array
default:"[]"
Template names or glob-style patterns to exclude from inspection. Supports * wildcards.
excluded_templates:
    - 'admin/*'
    - 'email/*'
excluded_blocks
array
default:"[]"
Block names or glob-style patterns to exclude. Supports * wildcards.
excluded_templates_regex
array
default:"[]"
Additional exclusion patterns as regular expressions. Applied alongside excluded_templates.
excluded_templates_regex:
    - '/^email\//'
excluded_templates_prefixes
array
default:"[]"
Template name prefixes to exclude, for namespace-style filtering.
excluded_templates_prefixes:
    - '@Admin/'
    - 'components/'
excluded_blocks_regex
array
default:"[]"
Regular expression patterns for block exclusion.
enable_metrics
boolean
default:"true"
Collect template and block metrics (render counts, timing) in the Web Profiler. Set to false to reduce collector overhead.
inject_on_sub_requests
boolean
default:"false"
When true, inject inspector comments during sub-requests (e.g. when main content is rendered as a fragment via render(controller(...))). Enable this if all templates show “sub-request” and none get inspected.
Name of the cookie used to enable/disable the inspector. Change this if it conflicts with another cookie in your app.
max_injection_depth
integer
default:"0"
Maximum nesting depth for comment injection. 0 means unlimited. Reducing this can lower overhead on very deep template trees.
overlay_theme
string
default:"light"
Visual theme for the overlay popup. Accepted values: light, dark, auto.auto follows the system prefers-color-scheme setting.
overlay_compact
boolean
default:"false"
Use a compact tooltip style for the overlay popup.
reduced_motion
boolean
default:"false"
Minimize overlay animations. Set to true to respect accessibility preferences, or rely on the system prefers-reduced-motion media query.
keyboard_shortcut
string
default:"Ctrl+Shift+T"
Keyboard shortcut that toggles the inspector (same as the Enable checkbox; reloads the page). Set to an empty string to disable the shortcut.

Full example config

# config/packages/dev/nowo_twig_inspector.yaml
nowo_twig_inspector:
    # Extensions to instrument
    enabled_extensions:
        - '.html.twig'

    # Exclusion — glob patterns
    excluded_templates: []
    excluded_blocks: []

    # Exclusion — regex patterns
    excluded_templates_regex: []
    excluded_blocks_regex: []

    # Exclusion — prefix-based
    excluded_templates_prefixes: []

    # Metrics collection in Web Profiler
    enable_metrics: true

    # Sub-request injection
    inject_on_sub_requests: false

    # Cookie
    cookie_name: 'twig_inspector_is_active'

    # Nesting depth (0 = unlimited)
    max_injection_depth: 0

    # Overlay appearance
    overlay_theme: 'light'       # light | dark | auto
    overlay_compact: false
    reduced_motion: false

    # Keyboard shortcut (empty to disable)
    keyboard_shortcut: 'Ctrl+Shift+T'

Exclusion patterns

The three exclusion mechanisms can be combined:
MechanismExampleMatches
excluded_templates (glob)'admin/*'Any template whose path starts with admin/
excluded_templates_prefixes'@Admin/'Namespace-style paths like @Admin/dashboard.html.twig
excluded_templates_regex'/\.email\.twig$/'Any path ending in .email.twig
All three lists are checked in order; a template is excluded if it matches any of them.

Routes configuration

The “open in IDE” links require the bundle routes to be imported only in dev and test. The Flex recipe and install command both handle this automatically. If you need to add them manually:
# config/routes.yaml
when@dev:
    nowo_twig_inspector:
        resource: '@NowoTwigInspectorBundle/Resources/config/routes.yaml'

when@test:
    nowo_twig_inspector:
        resource: '@NowoTwigInspectorBundle/Resources/config/routes.yaml'
Never import the bundle routes without a when@dev / when@test guard. The controller returns 404 in production as a safety measure, but the routes themselves must not be registered in prod.

Build docs developers (and LLMs) love