Search code examples
phpsymfonykernelassetsassetic

Symfony2 Assetic dump when using multiple kernels


Using Symfony 2.7. I made my application in multiple kernels. My folder structure is like this:

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

Now when I want to install assets i simply do:

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

this works, however when I do:

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

it searches for files in web/ directory, not in web/candy/bundles/../.

Why is that and what can be the solutions?

My 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: ~

Solution

  • You should set the "write_to" directory in the config for each kernel.

    app/candy/config/config.yml

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

    app/vegetable/config/config.yml

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

    Just as a side note, why is it that you are using multiple kernels?
    I've heard the possibility of it but never seen the benefits so am interested in the thinking.