New in Symfony 2.4: Dumping the default Configuration for an Extension
Warning: This post is about an unsupported Symfony version.
Some of this information may be out of date.
Read the most recent Symfony Docs.
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>
|
Help the Symfony project!
As with any Open-Source project, contributing code or documentation is the most common way to help, but we also have a wide range of sponsoring opportunities.
New in Symfony 2.4: Dumping the default Configuration for an Extension symfony.com/index.php/blog/new-in-symfony-2-4-dumping-the-default-configuration-for-an-extension
Tweet thisComments
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)
Very useful indeed, as we don't need to check the online documentation to have it. (and to do copy/paste too)
Comments are closed.
To ensure that comments stay relevant, they are closed for old posts.
Nicolò Pignatelli said on Oct 17, 2013 at 15:40 #1