How do I fix "Add myBundle to the asseticBundle config" symfony2 exception?

Manish Basdeo picture Manish Basdeo · Aug 31, 2012 · Viewed 36.4k times · Source

When I am trying to use the TWIG {% javascript %} tag to link to my .js file it return me with the following exception :

An exception has been thrown during the compilation of a template ("You must add CompetitiongameBundle to the assetic.bundle config to use the {% javascripts %} tag in CompetitiongameBundle:game:index.html.twig.") in "CompetitiongameBundle:game:index.html.twig".

My index.html.twig looks like :

{% javascripts 'CompetitiongameBundle/Resources/views/public/js/*'%}
    <script type="text/javascript" src="{{ asset_url }}" ></script>
{% endjavascripts %}
Hello {{ name }}!

<a href='{{ nexturl }}' >Login</a>

My Bundle is already present in the config file when I do :

php app/console config:dump-reference assetic

How can I fix this ?

Answer

Shabbir Reshamwala picture Shabbir Reshamwala · Jan 9, 2013

Yes I tried and it solved the issue for me. For someone (like me) who doesn't know initially how to add then just:

  1. edit app/config/config.yml
  2. then go to assetic:
  3. under assetic: go to bundles: []
  4. and in bundles: [] //type your bundle name

for instance if your bundle is Acme\DemoBundle, then do the following

assetic:
   bundles: [ AcmeDemoBundle ]

No quotes around AcmeDemoBundle. That's it. (Symfony2)