New in Symfony 2.4: Dumping the default Configuration for an Extension

Contributed by
Wouter De Jong
in #8635.

Did you know that Symfony comes with a command that outputs the default configuration for a bundle extension?

1
$ ./app/console config:dump-reference twig

The output also contains documentation when provided by the extension:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
twig:
    exception_controller:  twig.controller.exception:showAction
    form:
        resources:

            # Default:
            - form_div_layout.html.twig

            # Example:
            - MyBundle::form.html.twig
    globals:

        # Examples:
        foo:                 "@bar"
        pi:                  3.14

        # Prototype
        key:
            id:                   ~
            type:                 ~
            value:                ~
    autoescape:           ~
    autoescape_service:   ~
    autoescape_service_method:  ~
    base_template_class:  ~ # Example: Twig_Template
    cache:                '%kernel.cache_dir%/twig'
    charset:              '%kernel.charset%'
    debug:                '%kernel.debug%'
    strict_variables:     ~
    auto_reload:          ~
    optimizations:        ~
    paths:                []

This feature is not new, but as of 2.4, you can choose between the YAML and the XML format:

1
$ ./app/console config:dump-reference twig --format=xml
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<!-- Default configuration for extension with alias: "twig" -->
<!-- Namespace: http://example.org/schema/dic/twig -->
<!-- base-template-class: Example: Twig_Template -->
<config
    exception-controller="twig.controller.exception:showAction"
    autoescape=""
    autoescape-service="null"
    autoescape-service-method="null"
    base-template-class=""
    cache="%kernel.cache_dir%/twig"
    charset="%kernel.charset%"
    debug="%kernel.debug%"
    strict-variables=""
    auto-reload=""
    optimizations=""
>

    <form>

        <!-- prototype -->
        <resource>form_div_layout.html.twig</resource>

    </form>

    <!-- prototype -->
    <global
        key="global key"
        id=""
        type=""
        value=""
    />

    <!-- prototype -->
    <path>value</path>

</config>

Comments

Really useful, thank you!
why is there no highlighting for the YAML snippet ? Is it disabled or is it broken because of the % at the beginning of the value which is a special char and YAML and so used to require quoting in YAML 1.1 (it is not required anymore in 1.2 because there is no ambiguity here, given that directives are allowed only at the beginning of a document, not in values)
Christophe, yes that's the problem. We have the same issues with the yaml highlighting in the docs
Christophe, yes that's the problem. We have the same issues with the yaml highlighting in the docs
Very useful indeed, as we don't need to check the online documentation to have it. (and to do copy/paste too)
Nice little feature, thanks for the tip !
Didn't know about that, cool stuff!

Comments are closed.

To ensure that comments stay relevant, they are closed for old posts.