AsseticBundle配置信息("assetic"根键)

3.4 版本
维护中的版本

从Symfony 2.8开始,Assetic已不再是Symofny标准版框架的自带内容。参考这篇文章以了解如何在你的程序中安装和开启Assetic。

完整的默认配置 

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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
assetic:
    debug:                "%kernel.debug%"
    use_controller:
        enabled:              "%kernel.debug%"
        profiler:             false
    read_from:            "%assetic.read_from%"
    write_to:             "%kernel.root_dir%/../web"
    java:                 /usr/bin/java
    node:                 /usr/bin/node
    ruby:                 /usr/bin/ruby
    sass:                 /usr/bin/sass
    # An key-value pair of any number of named elements
    # 一个可以是任意数量“已命名元素”的键值对
    variables:
        some_name:                 []
    bundles:

        # Defaults (all currently registered bundles):
        # 默认值(当前已注册的全部bundles)
        - FrameworkBundle
        - SecurityBundle
        - TwigBundle
        - MonologBundle
        - SwiftmailerBundle
        - DoctrineBundle
        - AsseticBundle
        - ...
    assets:
        # An array of named assets (e.g. some_asset, some_other_asset)
        # 一个“已命名资源”的数组(如,some_asset, some_other_asset)
        some_asset:
            inputs:               []
            filters:              []
            options:
                # A key-value array of options and values
                # 一个“选项-选项值”的键值型数组
                some_option_name: []
    filters:
        # An array of named filters (e.g. some_filter, some_other_filter)
        # 一个已命名filters的数组(如,some_filter, some_other_filter)
        some_filter:                 []
    workers:
        # see https://github.com/symfony/AsseticBundle/pull/119
        # Cache can also be busted via the framework.assets.version
        # setting - see the "framework" configuration section
        # 参考 https://github.com/symfony/AsseticBundle/pull/119
        # 缓存可以被框架的framework.assets.version击破
        # 如何设置 - 参考“framework根键”之配置
        cache_busting:
            enabled:              false
    twig:
        functions:
            # An array of named functions (e.g. some_function, some_other_function)
            # 一个已命名functions的数组(如,some_function, some_other_function)
            some_function:                 []
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?xml version="1.0" encoding="UTF-8"?>
<container xmlns="http://symfony.com/schema/dic/services"
    xmlns:assetic="http://symfony.com/schema/dic/assetic"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://symfony.com/schema/dic/services
        http://symfony.com/schema/dic/services/services-1.0.xsd
        http://symfony.com/schema/dic/assetic
        http://symfony.com/schema/dic/assetic/assetic-1.0.xsd">
 
    <assetic:config
        debug="%kernel.debug%"
        use-controller="%kernel.debug%"
        read-from="%assetic.read_from%"
        write-to="%kernel.root_dir%/../web"
        java="/usr/bin/java"
        node="/usr/bin/node"
        sass="/usr/bin/sass">
 
        <!-- Defaults (all currently registered bundles) -->
        <assetic:bundle>FrameworkBundle</assetic:bundle>
        <assetic:bundle>SecurityBundle</assetic:bundle>
        <assetic:bundle>TwigBundle</assetic:bundle>
        <assetic:bundle>MonologBundle</assetic:bundle>
        <assetic:bundle>SwiftmailerBundle</assetic:bundle>
        <assetic:bundle>DoctrineBundle</assetic:bundle>
        <assetic:bundle>AsseticBundle</assetic:bundle>
        <assetic:bundle>...</assetic:bundle>
 
        <assetic:asset>
            <!-- prototype -->
            <assetic:name>
                <assetic:input />
 
                <assetic:filter />
 
                <assetic:option>
                    <!-- prototype -->
                    <assetic:name />
                </assetic:option>
            </assetic:name>
        </assetic:asset>
 
        <assetic:filter>
            <!-- prototype -->
            <assetic:name />
        </assetic:filter>
 
        <assetic:twig>
            <assetic:functions>
                <!-- prototype -->
                <assetic:name />
            </assetic:functions>
        </assetic:twig>
    </assetic:config>
</container>

本文,包括例程代码在内,采用的是 Creative Commons BY-SA 3.0 创作共用授权。

登录symfonychina 发表评论或留下问题(我们会尽量回复)