English spoken conference

Symfony 5: The Fast Track

A new book to learn about developing modern Symfony 5 applications.

Support this project

Configuration Reference

1.3 version
Maintained Unmaintained
1.2

Configuration Reference

The BlockBundle can be configured under the cmf_block key in your application configuration. When using XML, you can use the http://cmf.symfony.com/schema/dic/block namespace.

The BlockBundle automatically changes some defaults and adds configuration to the SonataBlockBundle to make the integration work seamlessly. See the updated SonataBlockBundle defaults for more information.

Configuration

persistence

phpcr

This defines the persistence driver. The default configuration of persistence is the following configuration:

  • YAML
    1
    2
    3
    4
    5
    6
    cmf_block:
        persistence:
            phpcr:
                enabled:                  false
                block_basepath:           /cms/content
                manager_name:             ~
    
  • XML
     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    <?xml version="1.0" charset="UTF-8" ?>
    <container xmlns="http://symfony.com/schema/dic/services">
    
        <config xmlns="http://cmf.symfony.com/schema/dic/block">
            <persistence>
                <phpcr
                    enabled="false"
                    block-basepath="/cms/content"
                    manager-name="null"
                />
            </persistence>
        </config>
    
    </container>
    
  • PHP
    1
    2
    3
    4
    5
    6
    7
    8
    9
    $container->loadFromExtension('cmf_block', array(
        'persistence' => array(
            'phpcr' => array(
                'enabled'                  => false,
                'block-basepath'           => '/cms/content',
                'manager_name'             => null,
            ),
        ),
    ));
    
enabled

type: boolean default: false

If true, PHPCR is enabled in the service container.

If the CoreBundle is registered, this will default to the value of cmf_core.persistence.phpcr.enabled.

PHPCR can be enabled by multiple ways such as:

  • YAML
    1
    2
    3
    4
    5
    6
    phpcr: ~ # use default configuration
    # or
    phpcr: true # straight way
    # or
    phpcr:
        manager: ... # or any other option under 'phpcr'
    
  • XML
     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    <persistence>
        <!-- use default configuration -->
        <phpcr />
    
        <!-- or setting it the straight way -->
        <phpcr>true</phpcr>
    
        <!-- or setting an option under 'phpcr' -->
        <phpcr manager="..." />
    </persistence>
    
  • PHP
     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    $container->loadFromExtension(..., array( // bundle configuration key, e.g. cmf_menu
        // ...
        'persistence' => array(
            'phpcr' => null, // use default configuration
            // or
            'phpcr' => true, // straight way
            // or
            'phpcr' => array(
                'manager' => '...', // or any other option under 'phpcr'
            ),
        ),
    ));
    
block_basepath

type: string default: /cms/content

The basepath for blocks in the PHPCR tree.

If the CoreBundle is registered, this will default to the value of %cmf_core.persistence.phpcr.basepath%/content.

manager_name

type: string default: null

The name of the Doctrine Manager to use. null tells the manager registry to retrieve the default manager.

If the CoreBundle is registered, this will default to the value of cmf_core.persistence.phpcr.manager_name.

twig

cmf_embed_blocks

The BlockBundle provides a Twig filter cmf_embed_blocks that looks through the content and looks for special tags to render blocks.

See embed blocks in content for using the cmf_embed_blocks filter.

prefix

type: string default: %embed-block|

The part before the actual path to the block.

postfix

type: string default: |end%

The part after the actual path to the block.

caches

The BlockBundle integrates with the SonataCacheBundle to provide several caching solutions.

varnish

This extends the default VarnishCache adapter of the SonataCacheBundle.

  • YAML
     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    # app/config/config.yml
    framework:
        # ...
        esi: { enabled: true }
        # enable FragmentListener to automatically validate and secure fragments
        fragments: { path: /_fragment }
        # add varnish server ip-address(es)
        trusted_proxies: [192.0.0.1, 10.0.0.0/8]
    
    cmf_block:
        # ...
        caches:
            varnish:
                token: a unique security key # a random one is generated by default
                servers:
                    - varnishadm -T 127.0.0.1:2000 {{ COMMAND }} "{{ EXPRESSION }}"
    
  • XML
     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    <!-- app/config/config.xml -->
    <?xml version="1.0" encoding="UTF-8" ?>
    <container xmlns="http://symfony.com/schema/dic/services">
    
        <config xmlns="http://cmf.symfony.com/schema/dic/block">
            <caches>
                <!-- token: a random one is generated by default -->
                <varnish token="a unique security key">
                    <server>varnishadm -T 127.0.0.1:2000 {{ COMMAND }} "{{ EXPRESSION }}"</server>
                </varnish>
            </caches>
        </config>
    
    </container>
    
  • PHP
     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    // app/config/config.php
    $container->loadFromExtension('cmf_block', array(
        // ...
        'caches' => array(
            'varnish' => array(
                'token' => 'a unique security key', // a random one is generated by default
                'servers' => array(
                    'varnishadm -T 127.0.0.1:2000 {{ COMMAND }} "{{ EXPRESSION }}"',
                ),
            ),
        ),
    ));
    
token

type: string default: hash('sha256', uniqid(mt_rand(), true))

A unique secret key. A random one is generated by default.

servers

type: array

ssi

This extends the default SsiCache adapter of the SonataCacheBundle.

  • YAML
    1
    2
    3
    4
    5
    6
    # app/config/config.yml
    cmf_block:
        # ...
        caches:
            ssi:
               token: a unique security key # a random one is generated by default
    
  • XML
     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    <!-- app/config/config.xml -->
    <?xml version="1.0" encoding="UTF-8" ?>
    <container xmlns="http://symfony.com/schema/dic/services">
    
        <config xmlns="http://cmf.symfony.com/schema/dic/block">
            <caches>
                <!-- token: a random one is generated by default -->
                <ssi
                    token="a unique security key"
                />
            </caches>
        </config>
    
    </container>
    
  • PHP
    1
    2
    3
    4
    5
    6
    7
    8
    9
    // app/config/config.php
    $container->loadFromExtension('cmf_block', array(
        // ...
        'caches' => array(
            'ssi' => array(
                'token' => 'a unique security key', // a random one is generated by default
            ),
        ),
    ));
    
token

type: string default: hash('sha256', uniqid(mt_rand(), true))

A unique secret key. A random one is generated by default.

This work, including the code samples, is licensed under a Creative Commons BY-SA 3.0 license.