使用多个内核时Symfony2 Assetic转储

时间:2016-04-15 10:00:46

标签: php symfony kernel assets assetic

使用Symfony 2.7。我在多个内核中创建了我的应用程序。我的文件夹结构如下:

Project
 |   
 +-- app/
 |  |  
 |  +-- candy/    // all config, parameters, kernel for candy application
 |  +-- vegetable/  // all config, parameters, kernel for vegetable application
 |    
 +-- src/ 
 +-- bin/
 +-- vendor/
 |  
 +-- web/
    |
    +-- candy/  // all assets, images, js etc. for candy application
    +-- vegetable/ // all assets, images, js etc. for vegetable application

现在,当我想安装资产时,我只是这样做:

php app/candy/console assets:install web/candy/

这有效,但是当我这样做时:

php app/candy/console assetic:dump web/candy/

它搜索web/目录中的文件,而不是web/candy/bundles/../

为什么会这样,解决方案是什么?

我的base.html.twig:

{% block stylesheets %}
    {% stylesheets
    'bundles/mpshop/css/jquery-ui.css'
    'bundles/mpshop/css/bootstrap.min.css'
    'bundles/mpshop/css/style.css'
    'bundles/mpshop/css/docs.css'
    'bundles/mpshop/css/lightbox.css'
    'bundles/mpshop/css/bootstrap-select.css'
    'bundles/mpshop/css/style_custom.css'
    'bundles/mpshop/css/responsive.css'
    'bundles/mpshop/slick/slick.css'
    'bundles/mpshop/slick/slick-theme.css'
    'bundles/mpshop/css/fonts_googleapis.css'
    filter='cssrewrite'
    %}
    <link rel="stylesheet" href="{{ asset_url }}" />

    {% endstylesheets %}
    <link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css">
{% endblock %}

{% block javascripts %}
    {% javascripts
    'bundles/mpshop/js/jquery-1.11.3.min.js'
    'bundles/mpshop/js/jquery-ui.js'
    'bundles/mpshop/js/migrate.js'
    'bundles/mpshop/js/bootstrap.min.js'
    'bundles/mpshop/js/bootstrap-select.js'
    'bundles/mpshop/js/search.js'
    'bundles/mpshop/js/ckeditor.js'
    'bundles/mpshop/js/jquery.lightbox-0.5.js'
    'bundles/mpshop/js/lightbox.js'
    'bundles/mpshop/slick/slick.js'
    'bundles/mpshop/js/custom.js'
    'bundles/mpshop/js/scroll-to-top.js'
    'bundles/mpshop/js/jquery.smooth_scroll.js'
    %}
    <script src="{{ asset_url }}"></script>
    {% endjavascripts %}

config.yml:

assetic:
    debug:          "%kernel.debug%"
    use_controller: "%kernel.debug%"
    bundles:        [ EDBlogBundle, ApplicationEDBlogBundle ]
    #java: /usr/bin/java
    filters:
        cssrewrite: ~

1 个答案:

答案 0 :(得分:1)

你应该设置&#34; write_to&#34;每个内核的配置中的目录。

应用程序/糖果/配置/ config.yml

assetic:
    //...
    write_to:             '%kernel.root_dir%/../../web/candy'

应用程序/蔬菜/配置/ config.yml

assetic:
    //...
    write_to:             '%kernel.root_dir%/../../web/vegetable'

正如旁注,为什么你要使用多个内核? 我已经听过它的可能性,但从未见过这样的好处,所以对这个想法感兴趣。