File tree

2 files changed

+77
-9
lines changed

2 files changed

+77
-9
lines changed
Original file line numberDiff line numberDiff line change
@@ -251,10 +251,10 @@ application should greet you:
251251
.. code-block:: text
252252
253253
http://localhost/app.php/hello/Ryan
254-
254+
255255
If you get an error, it's likely because you need to clear your cache
256256
by running:
257-
257+
258258
.. code-block:: bash
259259
260260
php app/console cache:clear --env=prod --no-debug
@@ -723,7 +723,7 @@ format you prefer:
723723
imports:
724724
- { resource: parameters.yml }
725725
- { resource: security.yml }
726-
726+
727727
framework:
728728
secret: %secret%
729729
charset: UTF-8
@@ -744,7 +744,7 @@ format you prefer:
744744
<import resource="parameters.yml" />
745745
<import resource="security.yml" />
746746
</imports>
747-
747+
748748
<framework:config charset="UTF-8" secret="%secret%">
749749
<framework:router resource="%kernel.root_dir%/config/routing.xml" />
750750
<!-- ... -->
@@ -803,6 +803,26 @@ options of each feature.
803803

804804
* *PHP*: Very powerful but less readable than standard configuration formats.
805805

806+
Default Configuration Dump
807+
~~~~~~~~~~~~~~~~~~~~~~~~~~
808+
809+
.. versionadded:: 2.1
810+
The ``config:dump-reference`` command was added in Symfony 2.1
811+
812+
You can dump the default configuration for a bundle in yaml to the console using
813+
the ``config:dump-reference`` command. Here is an example of dumping the default
814+
FrameworkBundle configuration:
815+
816+
.. code-block:: text
817+
818+
app/console config:dump-reference FrameworkBundle
819+
820+
.. note::
821+
822+
See the cookbook article: :doc:`How to expose a Semantic Configuration for
823+
a Bundle</cookbook/bundles/extension>` for information on adding
824+
configuration for your own bundle.
825+
806826
.. index::
807827
single: Environments; Introduction
808828

Original file line numberDiff line numberDiff line change
@@ -18,19 +18,19 @@ as integration of other related components:
1818
.. configuration-block::
1919

2020
.. code-block:: yaml
21-
21+
2222
framework:
2323
# ...
2424
form: true
2525
2626
.. code-block:: xml
27-
27+
2828
<framework:config>
2929
<framework:form />
3030
</framework:config>
3131
3232
.. code-block:: php
33-
33+
3434
$container->loadFromExtension('framework', array(
3535
// ...
3636
'form' => true,
@@ -304,7 +304,7 @@ option is passed and set to true::
304304
// prepare your $config variable
305305

306306
$loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
307-
307+
308308
if (isset($config['enabled']) && $config['enabled']) {
309309
$loader->load('services.xml');
310310
}
@@ -470,7 +470,7 @@ that an unsupported option was passed::
470470
$processor = new Processor();
471471
$configuration = new Configuration();
472472
$config = $processor->processConfiguration($configuration, $configs);
473-
473+
474474
// ...
475475
}
476476

@@ -484,6 +484,54 @@ normalization and advanced merging. The best way to see this in action is
484484
to checkout out some of the core Configuration classes, such as the one from
485485
the `FrameworkBundle Configuration`_ or the `TwigBundle Configuration`_.
486486

487+
Default Configuration Dump
488+
~~~~~~~~~~~~~~~~~~~~~~~~~~
489+
490+
.. versionadded:: 2.1
491+
The ``config:dump-reference`` command was added in Symfony 2.1
492+
493+
The ``config:dump-reference`` command allows a bundle's default configuration to
494+
be output to the console in yaml.
495+
496+
As long as your bundle's configuration is located in the standard location
497+
(``YourBundle\DependencyInjection\Configuration``) and does not have a
498+
``__constructor()`` it will work automatically. If you have a something
499+
different your ``Extension`` class will have to override the
500+
``Extension::getConfiguration()`` method. Have it return an instance of your
501+
``Configuration``.
502+
503+
Comments and examples can be added to your configuration nodes using the
504+
``->setInfo()`` and ``->setExample()`` methods::
505+
506+
// src/Acme/HelloBundle/DependencyExtension/Configuration.php
507+
namespace Acme\HelloBundle\DependencyInjection;
508+
509+
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
510+
use Symfony\Component\Config\Definition\ConfigurationInterface;
511+
512+
class Configuration implements ConfigurationInterface
513+
{
514+
public function getConfigTreeBuilder()
515+
{
516+
$treeBuilder = new TreeBuilder();
517+
$rootNode = $treeBuilder->root('acme_hello');
518+
519+
$rootNode
520+
->children()
521+
->scalarNode('my_type')
522+
->defaultValue('bar')
523+
->setInfo('what my_type configures')
524+
->setExample('example setting')
525+
->end()
526+
->end()
527+
;
528+
529+
return $treeBuilder;
530+
}
531+
532+
This text appears as yaml comments in the output of the ``config:dump-reference``
533+
command.
534+
487535
.. index::
488536
pair: Convention; Configuration
489537

0 commit comments

Comments
 (0)