Assetic unable to find file
Asked Answered
F

3

13

I am trying to link a css file (that lives in a bundle) inside a twig template :

{% stylesheets 
    '@AcmeFooBundle/Resources/public/css/bootstrap.min.css' 
%}
    <link href="{{ asset_url }}" rel="stylesheet"/>
{% endstylesheets %}

The first error message I get is:

You must add AcmeFooBundle to the assetic.bundle config...

This is the config :

# Assetic Configuration
assetic:
    debug:          %kernel.debug%
    use_controller: false
    bundles:        []
    #java: /usr/bin/java
    filters:
        cssrewrite: ~
        #closure:
        #    jar: %kernel.root_dir%/Resources/java/compiler.jar
        #yui_css:
        #    jar: %kernel.root_dir%/Resources/java/yuicompressor-2.4.7.jar

Then I try to add AcmeFooBundle in the bundles directive but then I get an error:

Unable to find file....

I can't understand what I am doing wrong here...

Dumping the default configs of the assetic configuration in the console (using php app/console config:dump-reference assetic ) I can see AcmeFooBundle bundle listed in the bundles directive...

Fiber answered 29/4, 2012 at 23:35 Comment(0)
B
28

Unless you need to whitelist some bundles for Assetic, just remove the bundles option from the config.

Brotherhood answered 30/4, 2012 at 4:13 Comment(2)
thank u elnur for you response. I tried to remove the bundles directive but still I get an, "unable to find..." errorFiber
add AcmeFooBundle to the config: bundles: [AcmeFooBundle] (but dont ask me why)Clayton
C
14

The following works for me:

  1. Create bundle e.g.:

    php app/console generate:bundle --namespace=Acme/Bundle/BlogBundle --no-interaction
    

    See: Generating a New Bundle Skeleton

  2. Add Assetic imports as the following:

    {% javascripts '@AcmeBlogBundle/Resources/public/js/*' %}
    <script type="text/javascript" src="{{ asset_url }}"></script>
    {% endjavascripts %}
    
  3. Add Bundle to assetic config:

    # Assetic Configuration
    assetic:
        ...
        bundles:        ['AcmeBlogBundle']
        ...
    
Chelate answered 26/12, 2012 at 14:44 Comment(0)
L
3

I had this same issue and elnur's suggestion worked. Here's my assetic config for your reference

# Assetic Configuration
assetic:
    debug:          %kernel.debug%
    use_controller: false
    #bundles:        [ ]
    #java: /usr/bin/java
    filters:
        cssrewrite: ~
        #closure:
        #    jar: %kernel.root_dir%/Resources/java/compiler.jar
        yui_css:
            jar: "%kernel.root_dir%/Resources/java/yuicompressor-2.4.7.jar"
        yui_js:
            jar: "%kernel.root_dir%/Resources/java/yuicompressor-2.4.7.jar"
Legalese answered 28/7, 2012 at 5:14 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.